• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterators & enumerators

 
Harry Singh
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Harry Singh
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, the actual name of the class is Enumeration not Enumerator .
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And even I am not a genius every day. Or every other day. Only days without "y" in them. :roll:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic