top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is an Iterator in java?

0 votes
362 views
What is an Iterator in java?
posted Mar 3, 2016 by Diya Borda

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

To generate successive elements from a series, we can use java iterator. It is an improvement over Enumeration interface. Iterator takes the place of Enumeration since jdk 1.2

It is a nice utility for collections. Every collection is unique on its own and imagine if we have have to write logic on our own for every collection when there is a need to iterate it. Instead, java forces a collection to deliver an iterator.

These nice utilities makes java lovable, isn’t it?

Important points to note:

We can iterate only in one direction
Iteration can be done only once. If you reach the end of series its done. If we need to iterate again we should get a new Iterator.

answer Mar 3, 2016 by Karthick.c
...