Technical Discussion :: Java
Home > Technical Interview Q&A > Java > Discussion
11 / 66
What is an Iterator ? How do you traverse through a collection using its Iterator?
Answer:
Iterator allows to traverse the collection and also it has methods which enables to obatin or remove elements. ListIterator adds the feature of traversing the list bi-directionally, also modify the elememts.
Eg.: Iterator itr = al.iterator();
while(itr.hasNext()) {}
Asked In ::
![q4interview-technical-questions-answers-user-icon](https://q4interview.com/images/q4interview-technical-questions-answers-user-icon.png)
Varun Kumar Rai
13 Oct, 2019 1:07 PM
Iterator allows to traverse the collection and also it has methods which enables to obatin or remove elements. ListIterator adds the feature of traversing the list bi-directionally, also modify the elememts.
Eg.: Iterator itr = al.iterator();
while(itr.hasNext()) {}
![q4interview-technical-questions-answers-user-icon](https://q4interview.com/images/q4interview-technical-questions-answers-user-icon.png)
Shaun
23 Jul, 2019 3:28 PM
Iterator allows us to traverse the elements in the collection.