UML class diagram

Java's Iterator interface is part of the java.util package and is a member of the Java collections framework. As you can see from the UML class diagram, the interface includes four methods:

UML class diagram i nterface Iterator

The forEachRemaining() method iterates through an object's elements. The hasNext() method returns a Boolean value depending on whether there are more iterations to go through. The next() method simply returns the next sequential iteration element. The final method, remove(), removes that last iterated element from the object.