my dog learned polymorphism*
The moose likes Beginning Java and the fly likes Difference between enuernation and Iterator in Java Collection. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between enuernation and Iterator in Java Collection." Watch "Difference between enuernation and Iterator in Java Collection." New topic
Author

Difference between enuernation and Iterator in Java Collection.

Prabhat Ranjan
Ranch Hand

Joined: Oct 04, 2006
Posts: 391
Hi,

As we know Enumeration is deprecated Interface in Java Collection..

So what is the exact difference between enuernation and Iterator .


Please share !

Regards,
Prabhat
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Well, they're interfaces, so the only differences are the names and signatures of the methods. Iterator has shorter method names, which don't clutter your code as much, and it has the "remove()" method, which Enumeration lacks. That's it.


[Jess in Action][AskingGoodQuestions]
Prabhat Ranjan
Ranch Hand

Joined: Oct 04, 2006
Posts: 391
yes correct !

thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Enumeration is not deprecated, it is merely discouraged. It's the same as Vector vs ArrayList.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
wood burning stoves
 
subject: Difference between enuernation and Iterator in Java Collection.
 
Similar Threads
hashpmap and dictionary and hashtable?
iterator vs Enumeration
Iterator vs Enumeration
enumeration and iterator difference
differences