This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
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 Elasticsearch in Action this week in the Big Data 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: 397
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: 24189
    
  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: 397
yes correct !

thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19911
    
  23

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between enuernation and Iterator in Java Collection.