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