For classes implementing abstract data types such as stacks, queues, lists, etc. that store collections of items, the Iterator interface provides a common way to access the items one at a time independent of the underlying implementation of the class.
public class Iterator<E>
{
public boolean hasNext();
public E next();
public void remove();
}
The remove() method is "optional". T should throw UnsupportedOperationException if isn't implemented to actually remove an item.
But how do you get an Iterator for a Stack, Queue, or LinkedList?