11.08. Iterators in Java

Iterators in Java

  • Eclipse: Oxygen
  • Java: 1.8

The list of iterators in Java is shown here. The iterators are the same as for the foreach loop and do not have any additional features compared to the foreach loop. The list iterators have some interesting features like the previous one and more, which will be seen later.

In the following example, Iterator is used for iterating in the list. hasNext() method of iterator check for next element in the collection and next() method returns the current element.

Output

Contributed by: Poonam Tomar

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments