Possible Duplicate:
Difference between Java Enumeration and Iterator
I was reading this post “Difference between Iterator & Enumeration“
If can use either iterator methods or enumeration methods to perform the same action then what is the difference?
Where am I expected to use either of these interfaces?
Enumerators are part of legacy Java 1.0. Iterators only appeared in Java 1.2. To my knowledge, Enumerators are only kept for backward compatibility. As per the java docs for Enumerator, all new code should user the Iterator interface.
You should use Iterators when looping through a collection, list, set, etc or something that implements that Iterator interface. You can also use the “new” (Java 5) for loop construct to iterate over such a collection. Keep in mind, however, that the only safe way to remove an item from a collection when looping is to use the Iterator.remove() method.