Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between enuernation and Iterator in Java Collection.

 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes correct !

thanks
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Enumeration is not deprecated, it is merely discouraged. It's the same as Vector vs ArrayList.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic