Difference between Enumeration and Iterator ?

Both Enumeration and Iterator is used for traversing through the underlying Collection. Enumeration can traverse limited collection such as Vectors and HashTable. Whereas Iterator can be used to almost all the Collection. Enumeration is twice as fast as Iterator as it act as read-only interface on the other hand Iterator is much safer as it doesn’t allow any modification to the underlying collection when iterating if any modification occurred it will throw ConcurrentModificationException and hence the Iterators are called as fail-fast Iterator as they fail quickly when it encounters a change.

Since Enumeration act as the read-only interface it can simply traverse through the Collection. [Read more…]