!6
The Java Iterator Interface
■
The Java API has a generic interface called
Iterator<T> that specifies what methods are
required of an iterator
❑
public boolean hasNext();!
returns true if there are more elements to iterate
over
❑
public T next();!
returns the next element
❑
public void remove();!
removes the last element returned by the iterator
(optional operation)
■
It is in the java.util package of the Java API