Java Reference
In-Depth Information
public int
indexOf(Object target)
Returns the index of the fi rst element that is equal to
target
. Uses the method
equals
of the
object
target
to test for equality. Returns
−1
if
target
is not found.
Throws
:
ClassCastException
if the type of
target
is incompatible with the calling object (optional).
NullPointerException
if
target
is
null
and the calling object does not support
null
elements (optional).
public int
lastIndexOf(Object target)
Returns the index of the last element that is equal to
target
. Uses the method
equals
of the
object
target
to test for equality. Returns
−1
if
target
is not found.
Throws:
ClassCastException
if the type of
target
is incompatible with the calling object (optional).
NullPointerException
if
target
is
null
and the calling object does not support
null
elements (optional).
public
List<T> subList(
int
fromIndex,
int
toIndex)
Returns a
view
of the elements at locations
fromIndex
to
toIndex
of the calling object; the
object at
fromIndex
is included; the object, if any, at
toIndex
is not included. The
view
uses
references into the calling object; so, changing the
view
can change the calling object. The
returned object will be of type
List<T>
but need not be of the same type as the calling object.
Returns an empty
List<T>
if
fromIndex
equals
toIndex
.
Throws:
IndexOutOfBoundsException
if
fromIndex
and
toIndex
do not satisfy:
0 <= fromIndex <= toIndex <= size()
.
ListIterator<T> listIterator()
Returns a list iterator for the calling object. (Iterators are discussed in Section 16.3.)
ListIterator<T> listIterator(
int
index)
Returns a list iterator for the calling object starting at
index
. The fi rst element to be returned by
the iterator is the one at
index
. (Iterators are discussed in Section 16.3.)
Throws:
IndexOutOfBoundsException
if
index
does not satisfy:
0 <= index <= size()
public
T get
(
int
index)
Returns the object at position
index
.
Throws an
IndexOutOfBoundsException
if the
index
is not in the range:
0 <= index < size()
.