The list interface extends collection and declares the behavior of a collection that stores a sequence of elements. Elements can be inserted or accessed by their position in the list, using a zero-based index. A list may contain duplicate elements. In addition to the methods defined by collection interface, the list interface defines some of its own methods.
Void add (int index, object obj):
Inserts object into the invoking list at the value passed in index. Any pre-existing elements at or beyond the point of insertion are shifted-up. Thus, no elements are over written.
Boolean addall (int index, collection c):
Inserts all elements of ‘c’ into the invoking list at the location passed in index, any pre-existing elements at or beyond the point of insertion are shifted up. Thus, no elements are over written, returns true if the invoking list changes and returns false otherwise.
Object get (int index):
Returns the object stored at the specified index within the invoking collection.
Int indexof (object obj):
Returns the index of the firstinstance of object in the invoking list, if object is not element of the list, then -1 is returned.
Int lastindexof (object obj):
Returns the index of the lastinstance of object in the invoking list, if object is not an element of the list, then -1 is returned.
Object remove (int index):
Removes the elements present at the location specified by index from the invoking list and returns to deleted element. The resulting list (after deletion) is compacted i.e. the indexes of the subsequent elements are decremented by one.
Object set (int index, object obj):
Assigns object to the location specified by index within the invoking list.
List sublist (int start, int end):
Returns a list that includes elements from start to end -1 in the invoking list, elements in the returned list are also referred by the invoking object.