This interface represents an ordered
collection of objects. In Java 5.0
List is a
generic interface and the type variable
represents the type of the objects in the list. Each element in a
List has an index, or position, in the list, and
elements can be inserted, queried, and removed by index. The first
element of a
List has an index of
0. The last element in a list has index
addition to the methods defined by the superinterface,
List defines a
number of methods for working with its indexed elements.
get( ) and
set( ) query and set
the object at a particular index, respectively. Versions of
add( ) and
addAll( ) that take
index argument insert an object or
Collection of objects at a specified index. The
add( ) and
) that do not take an
argument insert an object or collection of objects at the end of the
List defines a version of
) that removes the object at a specified index.
iterator( ) method is just like the
iterator( ) method of
Collection, except that the
Iterator it returns is guaranteed to enumerate the
elements of the
List in order.
listIterator( ) returns a
ListIterator object, which is more powerful than a
Iterator and allows the list to be
modified while iteration proceeds.
can take an index argument to specify where in the list iteration
indexOf( ) and
lastIndexOf( ) perform linear searches from the beginning and end, respectively, ...