enfrptes

sendassignment@tutorspoint.com

List Interface Homework Help

What is List Interface?

The list interface extends the 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 the collection interface, the list interface defines some of its own methods.

What is Void add (int index, Object obj)?

Inserts object into the invoking list at the value passed in an index. Any pre-existing elements at or beyond the point of insertion are shifted-up. Thus, no elements are overwritten.

What is 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.

What is Object get (int index)?

Returns the object stored at the specified index within the invoking collection.

What is the 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.

What is the 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.

What is 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.

What is an Object set (int index, Object obj)?

Assigns the object to the location specified by the index within the invoking list.

What is a 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 to by the invoking object.