Tutorspoint offers java assignment help in List Interface Homework Help

 

List Interface

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 overwritten.

Boolean add all (int index, Collection c):

Inserts all elements of ā€˜cā€™ into the invoking list at the location passed in the index, any pre-existing elements at or beyond the point of insertion are shifted up. Thus, no elements are overwritten, 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 index of (object obj):

Returns the index of the first instance of an object in the invoking list, if the object is not an element of the list, then -1 is returned.

Int last index of (object obj):

Returns the index of the last instance of an object in the invoking list, if the 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.

List Interface Homework Help