Collection Framework - List Interface and its implementations

List interface extends the Collection interface. So it has all the methods available in the collection interface. On top of it, below are the methods added in the List interface :

Addition/Selection/Deletion methods :
  • add(int index, Object o) - Add an object to a specified index
  • addAll(int index, Collection coll) - Add a collection to a specified index
  • remove(int index) - Remove an object from the index
  • set(int index, Object o) - Set an object at a particular index
  • get(int index) - Get an object at a particular  index
Utility methods :
  • indexOf(Object o) - Index of Object o
  • lastIndexOf(Object o) - Since list support duplicates, this one returns the last index of o.
  • listIterator() - returns a list iterator that can be used to iterate over the list.

The implementations of List Interface are :
1. ArrayList
2. LinkedList
3. Vector
4. Stack

Comments

Popular posts from this blog

Collection Framework - HashSet And LinkedHashSet class

Collection Framework - Cursors in Java

Hashed data structures