File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes iterator vs Enumeration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "iterator vs Enumeration" Watch "iterator vs Enumeration" New topic
Author

iterator vs Enumeration

vara prasad
Ranch Hand

Joined: Dec 21, 2004
Posts: 47
what is the difference between iterator and Enumeration
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Iterator is newer than Enumeration, and its method names are shorter because it was felt that the old ones were too long and awkward. Also, Iterator has an optional method that lets you remove the current element from a collection -- Enumeration doesn't have that.

In any case, Iterator is meant as a replacement for Enumeration. You shouldn't use Enumeration unless you're forced to by a legacy API.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: iterator vs Enumeration