Scroll to top

List collection tutorial for Java Beginners

Here we will learn about the List interface and different implementation of it in details. List Interface which is in java.util package is a subtype of java.util.Collection Interface.

List Interface Salient Point

  1. It is a part of java.util package.
  2. It is a sub-type of java.util.Collection Interface
  3. List is an Ordered Collection. Means elements of List can be accessed in ordered way (By index).
  4. Allows Duplicate values.
  5. Allows NULL values.
  6. List has a special Iterator named ListIterator. It will help traverse list in both directions.
  7. List has full control on where each element is inserted.

Operations available to List Interface

  • Positional Access
  • Search
  • Iteration
  • Range View

Concrete Implementation of List Interface

  • java.util.ArrayList
  • java.util.LinkedList
  • java.util.Vector
  • java.util.Stack

Create List Instance

List listA = new ArrayList();
List listB = new LinkedList();
List listC = new Vector();
List listD = new Stack();

Adding Element in List

List listA = new ArrayList();
listA.add("element 1");
listA.add("element 2");
listA.add("element 3");
listA.add(0, "element 0");

Access an Element

Syntax : E set(int index, E element);

Purpose : Used to return element at specified position

Return : Returns the element at specified position in given list.

Replace an Element

Syntax : E set(int index, E element);

Purpose: Used to replace an element at specified position in List.

Return: Returns the element replaced.

Performance Point

  • List interface have methods to search for an Object. But same should not be used as it will decrease the performance as in some implementation it will use linear search.
  • List can contain another list as an Element but HashCode and Equals will not apply to these lists and hence same should not be used.
Author avatar


  1. Michael

    I think there is a typo error in the section: Access an Element
    you said: Syntax : E set(int index, E element);
    Instead of: Syntax: E get(int index,E element);

  2. a

    If it is get then there should be only index parameter.

Post a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.