February 2017
Beginner
1056 pages
28h 57m
English
Iterator InterfaceThe Iterator interface is designed to be implemented in conjunction with classes whose objects are collections of elements. In a good implementation, repeated execution of the method next would visit all elements in the collection. The Iterator interface might be implemented by the collection class itself or by another class whose objects are iterators for the collection class. The Iterator interface specifies three methods and appears as follows:
public interface Iterator<E>
{
/**
Returns the next element. Throws a
NoSuchElementException if there is no next element.
**/
public E next();
/**
Returns true if an element is left for next to return.
*/
public boolean hasNext();
/**
Removes the last element that ...Read now
Unlock full access