Enumeration Vs Iterator

1. What are the differences between Enumeration & Iterator?

1. Trivial: Method Names are Improved as shown below:

2. Important: As shown in the above name, method "remove" has been added in iterator. Please note that this method is optional and not all implementations needs to implement this.

3. Historical: Iterator is successor of Enumeration. Thus without compelling reason (e.g. Legacy code) one may want to use Iterator. Quote from Java Doc: Iterator takes the place of Enumeration in the Java collections framework

Side note: Java Doc in Enumeration mentions all these differences: The functionality of this interface is duplicated by the Iterator interface. In addition, Iterator adds an optional remove operation, and has shorter method names. New implementations should consider using Iterator in preference to Enumeration

2. Are iterators Fail-Fast & Enumeration not?

No. In definition of iterator, it does not mention anything about fail-fast. But most implementations, e.g. Vector, Hashtable, HashMap, etc, all provide the fail-fast behavior of Iterators.

References: