List is an ordered collection of elements. Unlike Set, List allows duplicates. You can access the elements in the list by index.
The
List interface provides a ListIterator that allows element insertion
and replacement, and provides bidirectional access to the elements in
the list .
List
interface extends the Collection interface.
ArrayList,
LinkedList and Vector are the basic classes which implement List
interface.
As
Compared to set, List perform below operations
- Allows Duplicates
- Provides ListIterator for bidirectional traversal
- can add element at particular index
- Get the elements based on the index position
- Add collection of elements at particular index
- Remove element at particular index.
- Get the first and last index of element
public interface List<E> extends Collection<E>{ int size(); boolean isEmpty(); boolean contains(Object o); Iterator<E> iterator(); Object[] toArray(); <T> T[] toArray(T[] a); boolean add(E e); boolean remove(Object o); boolean containsAll(Collection<?> c); boolean addAll(Collection<? extends E> c); boolean addAll(int index, Collection<? extends E> c); boolean removeAll(Collection<?> c); boolean retainAll(Collection<?> c); void clear(); boolean equals(Object o); int hashCode(); E get(int index); E set(int index, E element); void add(int index, E element); E remove(int index); int indexOf(Object o); int lastIndexOf(Object o); ListIterator<E> listIterator(); ListIterator<E> listIterator(int index); List<E> subList(int fromIndex, int toIndex); }
Prevoius Next Home
No comments:
Post a Comment