deference between Iterator and Enumeration

 

Key

Iterator

Enumeration

Basic

In iterator we can read and remove element while traversing element in the collections

  Using Enumeration we can only read element during traversing element in the collections

Access

It can be used with any class

Of the collection frame work

It can be used only with legacy class of the collection framework such as a vector and Hash-Table

Fail-fast and fail

safe

Any changes in the collection  such us removing element from the collection during a thread is iterating collection then it throw

Concurrent  modification exception

Enumeration is fail safe in nature  It doesn’t throw concurrent modification exception

 

Comments

Blogs