An Iterator is an object that enables you to navigate through a collection and to remove elements from the collection selectively, if desired. You get an Iterator for a collection by calling its iterator method. The following is the Iterator interface . public interface Iterator<E> { boolean hasNext(); E next(); void remove(); //optional } The hasNext() method returns true if the iteration has more elements, and the next() method returns the next element in the iteration. The remove() method removes the last element that was returned by next from the underlying Collection . The remove method may be called only once per call to next and throws an exception if this rule is violated. [ Note : Iterator.remove is the only safe way to modify a...
"WE BELIEVE THAT KNOWLEDGE IS POWER." Start your exploration from today!