Java Reference
In-Depth Information
boolean hasPrevious() returnstruewhenthislistiteratorhasmoreele-
ments when traversing the list in the reverse direction.
E next() returns the next element in this list and advances the cursor po-
sition. This method throws NoSuchElementException when there is no
next element.
int nextIndex() returnstheindexoftheelementthatwouldbereturned
by a subsequent call to next() , or the size of the list when at the end of the
list.
E previous() returns the previous element in this list and moves the
cursor position backwards. This method throws NoSuchElementExcep-
tion when there is no previous element.
int previousIndex() returnstheindexoftheelementthatwouldbere-
turned by a subsequent call to previous() , or -1 when at the beginning of
the list.
void remove() removes from the list the last element that was returned
by next() or previous() . This call can be made only once per call to
next() or previous() . Furthermore, it can be made only when add()
has not been called after the last call to next() or previous() . This
method throws UnsupportedOperationException when this list iter-
ator does not support remove() , and IllegalStateException when
neither next() nor previous() hasbeencalled,or remove() or add()
has already been called after the last call to next() or previous() .
void set(E e) replacesthelastelementreturnedby next() or previ-
ous() with element e . This call can be made only when neither remove()
nor add() has been called after the last call to next() or previous() .
This method throws UnsupportedOperationException when this list
iterator does not support set() , ClassCastException when e 'sclass is
inappropriateforthislist, IllegalArgumentException whensomeprop-
erty of e prevents it from being added to this list, and IllegalStateEx-
ception when neither next() nor previous() has been called, or re-
move() or add() has already been called after the last call to next() or
previous() .
A ListIterator instancedoesnothavetheconceptofacurrentelement.Instead,
it has the concept of a cursor for navigating through a list. The nextIndex() and
previousIndex() methods return the cursor position , which always lies between
Search WWH ::




Custom Search