The List Interface
The List interface extends Collection and declares the behavior of a collection that stores a sequence of elements. Elements can be inserted 01′ 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, List defines some of its own,. Note again that several of these methods will throw an Unsupported Operation Exception if the collection cannot be modified, and a ClassCastexception is generated when one object is incompatible with another, such as when an attempt is made to add an incompatible object to a collection. To the versions of add( j and uc dAU() defined by Collection, List adds the methods add int, Object) and addAll(int, Collection). These methods insert elements at the specified index. Also, the semantics of add(Object) and addAll (Collection) defined by Collection are changed by List so that they’ add clements to the end of the list. To obtain the object stored at a specific location, call get( ) with the index of the object. To assign a value to an element in the list, call setting  specifying the index of the object to be changed. To find the index of an object, use ind Of ( ) or lastIndex () You elm obtain a sublist of a list by calling sub list ), specifying the beginning and ending indexes of the sublist. As you can imagine, sub List  makes list processing quite convenient.

[vfb id=1]

Share This