aspose file tools*
The moose likes Java in General and the fly likes Iterators & enumerators Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Iterators & enumerators" Watch "Iterators & enumerators" New topic
Author

Iterators & enumerators

Harry Singh
Ranch Hand

Joined: May 02, 2001
Posts: 124
Hi All,
Can anyone tell me the difference between Iterators & Enumerators.Which one is used and for which purpose.
Any links that could provide info about these topics would be of help.
Regards,
HArry
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Enumerator is a Java 1.1 class that is really out of date now, though some interfaces and classes still use it.
For any new code, you should use Iterator.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Harry Singh
Ranch Hand

Joined: May 02, 2001
Posts: 124
Hi Ron,
Thanks for the reply.Enumerators are an older version but still they are being used and may i know whats the basic differnce between enumerators and iterators and in what way are iterators are better then Enumerators.
Regards,
Harjinder
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Iterators have better (shorter) method names and are part of the Collections framework that was introduced in Java 1.2.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
And enumerator was the wrong wrong WRONG! name for the thing that iterates a set. Even the people at sun are not geniuses every day.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
By the way, the actual name of the class is Enumeration not Enumerator .
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
And even I am not a genius every day. Or every other day. Only days without "y" in them. :roll:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Iterators & enumerators
 
Similar Threads
Enumerations Vs Iterators
Question about Iterator Pattern ?
Two iterators
Iterator are fail safe while Enumeration is not
Vector supports iterators?