File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "iterator vs Enumeration" Watch "iterator vs Enumeration" New topic

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

Joined: Jul 08, 2003
Posts: 24195

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:
subject: iterator vs Enumeration
It's not a secret anymore!