javautilIterator
The java.util.Iterator interface is part of the Java standard library and provides a uniform way to traverse the elements of a collection in a forward direction. It is generic, declared as Iterator<E>, and is implemented by most Java collection classes such as ArrayList, LinkedList, HashSet, and the views of maps.
The core methods of Iterator are hasNext(), next(), and remove() (where remove is optional). hasNext() returns true
Usage typically involves obtaining an iterator from a collection via collection.iterator(), then looping while hasNext() is
Many iterators are fail-fast: if the underlying collection is structurally modified after the iterator is created
Notes: Iterator traverses elements forward only; to traverse bidirectionally, ListIterator offers additional capabilities. Implementations may vary