What is an Iterator ?
-
Enables you to cycle through a collection in the forward direction only, for obtaining or removing elements
-
just for loop
-
while loop
-
It is an class for storing objects
An Iterator in Java provides a uniform way to access elements of a collection sequentially, allowing both retrieval and removal of elements during iteration. It differs from simple loops (options B, C) which are control flow constructs, not a dedicated interface for traversing collections. Option D incorrectly describes it as a storage class rather than an access mechanism.
An Iterator is an object designed to traverse a collection one element at a time, moving only forward, and it exposes methods to retrieve or remove the current element as you go. It's not itself a loop construct (like for or while) or a storage container — it's the mechanism that lets you walk through whatever collection it's bound to, regardless of the collection's internal structure.