ü Extends the Collection interface.
ü Used to create lists of object references.
ü Provides additional methods to create a collection that stores elements in orderly fashion.
ü A List may contain duplicate elements.
ü The two general-purpose implementations of List are ArrayList and LinkedList.
public interface List extends Collection
An ordered collection (also known as a sequence).
All Known Implementing Classes: AbstractList, ArrayList, LinkedList, Vector
Some Important Methods | |
void | add(int index, Object element) Inserts the specified element at the specified position in this list. |
boolean | add(Object o) Appends the specified element to the end of this list. |
boolean | addAll(int index, Collection c) Inserts all of the elements in the specified collection into this list at the specified position |
void | clear() Removes all of the elements from this list |
boolean | contains(Object o) Returns true if this list contains the specified element. |
boolean | equals(Object o) Compares the specified object with this list for equality. |
Object | get(int index) Returns the element at the specified position in this list. |
int | indexOf(Object o) Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element. |
boolean | isEmpty() Returns true if this list contains no elements. |
Object | remove(int index) Removes the element at the specified position in this list. |
int | size() Returns the number of elements in this list. |
List | subList(int fromIndex, int toIndex) Returns a view of the portion of this list between the specified fromIndex , inclusive, and toIndex , exclusive. |
Object[] | toArray() Returns an array containing all of the elements in this list in proper sequence. |
0 comments :
Post a Comment