- List Interface is the child interface of collection interface.
- Vector and Stack class came in java 1.0 version and List interface along with ArrayList and LinkedList came in version java 1.2
- Hence Vector and Stack class are also called as legacy classes.
- We can differentiate duplicates by using index.
- We can preserve insertion order by using index, hence index plays very important role in list interface.
Features of List, When to go for list
- Duplicates are allowed.
- Insertion order is preserved.
- Size of data is not fixed
public interface List<E> extends Collection<E>{ }
Implementation Class of List interface are :
- ArrayList
- LinkedList
- Vector
- Stack extends Vector
Methods of List interface :
add(Object o)
add(int index,Object o)
addAll(int index, Collection c)
remove(int index)
get(int index)
set(int index, Object o)
indexOf(Object o)
lastIndexOf(Object o)