All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface com.sun.java.util.collections.Iterator

public interface Iterator
An iterator over a Collection. Iterator takes the place of java.util.Enumeration in the Java collections framework. Iterators differ from java.util.Enumerations in two ways:

See Also:
Collection, ListIterator, Enumeration

Method Index

 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 (optional operation).

Methods

 o hasNext
 public abstract boolean hasNext()
Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:
true if the Iterator has more elements.
 o next
 public abstract Object next()
Returns the next element in the interation.

Returns:
s 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 (optional operation). 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.

Throws: UnsupportedOperationException
remove is not supported by this Iterator.
Throws: IllegalStateException
next has not yet been called, or remove has already been called after the last call to next.

All Packages  Class Hierarchy  This Package  Previous  Next  Index