List interface

List interface
  • It is the child interface of Collection.
  • If we want to represent a group of individual objects as a single entity where duplicates are allow and insertion order is preserved. Then we should go for List.
  • Insertion order will be preserved by means of Index.
  • We can differentiate duplicate objects and we can maintain insertion order by means of index hence “index play very important role in List”.
  • List interface defines the following specific methods.
  1. boolean add(int index,Object o);
  2. boolean addAll(int index,Collectio c);
  3. Object get(int index);
  4. Object remove(int index);
  5. Object set(int index,Object new); //to replace
  6. int indexOf(Object o); // Returns index of first occurrence of “o”.
  7. int lastIndexOf(Object o);
  8. ListIterator listIterator();

List interface contains 4 classes

  1. ArrayList
  2. LinkedList
  3. VectorList
  4. Stack
List interface
Scroll to top