It provides methods to traverse collections safely and flexibly.
The Iterator interface provides `hasNext()`, `next()`, and `remove()` methods, enabling safe and flexible iteration over collections. Unlike the enhanced for loop, it allows element removal while iterating. For example, using `Iterator` for a product catalog allows you to traverse and modify the list dynamically: `Iterator it = catalog.iterator(); while(it.hasNext()) { Product p = it.next(); if (p.isExpired()) it.remove(); }`.
Additional Notes
How does the Iterator interface improve collection traversal?