E- the type of object returned by the iterator.
public interface Iterator<E>
If a collection has been changed since the iterator was created,
hasNext() may throw a
It is not possible to guarantee that this mechanism works in all cases of unsynchronized
concurrent modification. It should only be used for debugging purposes. Iterators with this
behavior are called fail-fast iterators.
Iterable and returning an
Iterator allows your
class to be used as a collection with the enhanced for loop.
|Modifier and Type||Method and Description|
Returns true if there is at least one more element, false otherwise.
Returns the next object and advances the iterator.
Removes the last object returned by
trueif there is a next element.
NoSuchElementException- if there are no more elements.
nextfrom the collection. This method can only be called once between each call to
java.lang.UnsupportedOperationException- if removing is not supported by the collection being iterated.
nexthas not been called, or
removehas already been called after the last call to