public interface ListIterator<E> extends Iterator<E>
Modifier and Type | Method and Description |
---|---|
void |
add(E object)
Inserts the specified object into the list between
next and
previous . |
boolean |
hasNext()
Returns whether there are more elements to iterate.
|
boolean |
hasPrevious()
Returns whether there are previous elements to iterate.
|
E |
next()
Returns the next object in the iteration.
|
int |
nextIndex()
Returns the index of the next object in the iteration.
|
E |
previous()
Returns the previous object in the iteration.
|
int |
previousIndex()
Returns the index of the previous object in the iteration.
|
void |
remove()
Removes the last object returned by
next or previous from
the list. |
void |
set(E object)
Replaces the last object returned by
next or previous
with the specified object. |
void add(E object)
next
and
previous
. The object inserted will be the previous object.object
- the object to insert.UnsupportedOperationException
- if adding is not supported by the list being iterated.ClassCastException
- if the class of the object is inappropriate for the list.IllegalArgumentException
- if the object cannot be added to the list.boolean hasNext()
boolean hasPrevious()
true
if there are previous elements, false
otherwise.previous()
E next()
next
in interface Iterator<E>
NoSuchElementException
- if there are no more elements.hasNext()
int nextIndex()
NoSuchElementException
- if there are no more elements.next()
E previous()
NoSuchElementException
- if there are no previous elements.hasPrevious()
int previousIndex()
NoSuchElementException
- if there are no previous elements.previous()
void remove()
next
or previous
from
the list.remove
in interface Iterator<E>
UnsupportedOperationException
- if removing is not supported by the list being iterated.IllegalStateException
- if next
or previous
have not been called, or
remove
or add
have already been called after
the last call to next
or previous
.void set(E object)
next
or previous
with the specified object.object
- the object to set.UnsupportedOperationException
- if setting is not supported by the list being iteratedClassCastException
- if the class of the object is inappropriate for the list.IllegalArgumentException
- if the object cannot be added to the list.IllegalStateException
- if next
or previous
have not been called, or
remove
or add
have already been called after
the last call to next
or previous
.