Iterator in Java

iterator

Iterators are used in the Collection framework in Java( ArrayList, LinkedList, HashMap, etc. ) to iterate the elements one by one.

There are three types:

  • Enumeration
  • Iterator
  • List Iterator

Enumeration Example:

OUTPUT :

Iterator Example:

The iterator() method is used to get an Iterator for any collection:

OUTPUT:

List Iterator Example:

The listIterator() method is used to get an Iterator for any collection:

OUTPUT:


Download Source Code :

About Manohar

I, Manohar am the founder and chief editor of ClarifyAll.com. I am working in an IT professional.

View all posts by Manohar →

One Comment on “Iterator in Java”

Leave a Reply