Java Iterator interface
An iterator is an interface that is used in place of Enumerations in the Java Collection Framework. Moreover, an iterator differs from the enumerations in two ways:
- Iterator permits the caller to remove the given elements from the specified collection during the iteration of the elements.
- Method names have been enhanced.
Iterator interface is a member connected with Java Collections Framework.
|forEachRemaining(Consumer<? super E>action)
||Performs the given action on each of the element until and unless all the elements have been processed or unless an exception is thrown by the action.
||Returns a true value if the more number of elements are encountered during iteration.
||Returns the next specified element during the iteration.
||Removes the last element from the collection as provided by the iterator.
Test it Now
The list is given as : [Welcome, to, our, website]
After the remove() method is called : [Welcome, to, our]