• Post Reply Bookmark Topic Watch Topic
  • New Topic

Enumerations Vs Iterators  RSS feed

 
Santosh Jagtap
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
why enumeration is not preffered rather iterators are.....

Thnks
 
Sandeep Jindal
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

An iterator over a collection. Iterator takes the place of Enumeration in the Java collections framework. Iterators differ from enumerations in two ways:


- Iterators allow the caller to remove elements from the underlying collection during the iteration with well-defined semantics.
- Method names have been improved.


Hope this clears.
 
Santosh Jagtap
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah it is but are there any more reasons?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See your other thread about legacy classes. Enumeration is a legacy class. Iterator, which is improved in several ways, was intended as a replacement.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If nothing else it's a much better name.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!