[all packages]
[package java.util]
[class hierarchy]
[index]
public interface java.util.Iterator<A>
(source file: Iterator.java)
java.lang.Object
|
+----java.util.Iterator<A>
The pure class interface.
public interface Iterator<A>
-
An iterator over a Collection. Iterator takes the place of Enumeration in
the Java collection framework. Iterators differ from Enumerations in two
ways:
- Iterators allow the caller to remove elements from the
underlying collection during the iteration with well-defined
semantics.
- Method names have been improved.
- See also:
- Collection, ListIterator, Enumeration
- hasNext()
-
Returns true if the iteration has more elements.
- next()
-
Returns the next element in the interation.
- remove()
-
Removes from the underlying Collection the last element returned by the
Iterator
hasNext
public abstract boolean hasNext();
-
Returns true if the iteration has more elements.
next
public abstract A next();
-
Returns the next element in the interation.
- Throws:
- NoSuchElementException -iteration has no more elements.
-
remove
public abstract void remove();
-
Removes from the underlying Collection the last element returned by the
Iterator . This method can be called only once per call to next The
behavior of an Iterator is unspecified if the underlying Collection is
modified while the iteration is in progress in any way other than by
calling this method. Optional operation.
- Throws:
- UnsupportedOperationException -remove is not supported
by this Iterator.
- IllegalStateException -next has not yet been called,
or remove has already been called after the last call
to next.
-
[all packages]
[package java.util]
[class hierarchy]
[index]
java.util.Iterator.html