/**
* An iterator over a collection. Iterator takes the place of
* Enumeration in the Java collections framework. Iterators differ
* from 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.
*
* This interface is a member of the Java Collections Framework.
*/
public interface Iterator<T> {
/**
* Returns true if the iteration has more elements.
*/
boolean hasNext();
/**
* Returns the next element in the iteration.
*/
T next();
/**
* Removes from the underlying collection the last element
* returned by the iterator (optional operation).
*/
void remove();
}
/**
* Implementing this interface allows an object to be the target of
* the "foreach" statement.
*/
public interface Iterable<T> {
/**
* Returns an iterator over a set of elements of type T.
*/
Iterator<T> iterator();
}