[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:

See also:
Collection, ListIterator, Enumeration

Methods

O hasNext()
Returns true if the iteration has more elements.
O next()
Returns the next element in the interation.
O remove()
Removes from the underlying Collection the last element returned by the Iterator

Methods

O hasNext
public abstract boolean hasNext();
Returns true if the iteration has more elements.

O next

public abstract A next();
Returns the next element in the interation.

Throws:
NoSuchElementException -iteration has no more elements.

O 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