List Interface in Java

  • Lists allow duplicate entries within the collection
  • Lists are an ordered collection much like an array
  • Lists grow automatically when needed
  • The list interface provides accessor methods based on index
  • The List interface extends the Collections interface and add the following method definitions:
    • void add(int index, Object)
    • boolean addAll(int index, Collection)
    • Object get(int index)
    • int indexOf(Object)
    • int lastIndexOf(Object)
    • ListIterator listIterator()
    • ListIterator listIterator(int index)
    • Object remove(int index)
    • Object set(int index, Object)
    • List subList(int fromIndex, int toIndex)

Java provides 3 concrete classes which implement the list interface
Vectors try to optimize storage requirements by growing and shrinking as required. Methods are synchronized (used for Multi threading)

ArrayList is roughly equivalent to Vector except that its methods are not synchronized.

LinkedList implements a doubly linked list of elements
Methods are not synchronized