E
- Type of element which is (not) iterated by an instance of this
object.public final class EmptyIterator<E>
extends java.lang.Object
implements java.util.Iterator<E>
Iterator
which manages no elements.
This is useful when a method must return an iterator, but the collection
which normally backs the iterator does not exist. This may occur, for
example, if a class lazily creates the backing collection, and it has not
yet done so at the time the method is called which must return an iterator
on that collection.Constructor and Description |
---|
EmptyIterator() |
Modifier and Type | Method and Description |
---|---|
boolean |
hasNext()
Indicates that there is no next element (since there is no backing
collection).
|
E |
next()
Throws an exception, since there is no next element to return.
|
void |
remove()
An unsupported operation for this implementation, since there is no
backing collection and nothing to remove.
|
public boolean hasNext()
hasNext
in interface java.util.Iterator<E>
false
.public E next()
java.util.Iterator
.next
in interface java.util.Iterator<E>
java.util.NoSuchElementException
- always.public void remove()
remove
in interface java.util.Iterator<E>
java.lang.UnsupportedOperationException
- always.