what is difference Enumeration and Iterator?

Enumeration vs Iterator
1. It is legacy interface and introduced in 1.0 version
It is non-legacy and introduced in 1.2 version
2.Applicable only for legacy classes and it is not universal cursor.
Applicable for any Collection implemented class object.
3.While iterating the elements we are not allowed to remove the objects just we can perform only read operation.
While iterating we can perform removal also in addition to read operation.
4.By using elements() method we can get Enumeration object.
By using iterator() method we can get Iterator object

1 comment:

  1. The functionality of Enumeration interface is duplicated by the Iterator interface.
    Iterator has a remove() method while Enumeration doesn't. Enumeration acts as Read-only interface, because it has the methods only to traverse and fetch the objects, where as using Iterator we can manipulate the objects also like adding and removing the objects. I have also blogged about
    difference between iterator and enumeration here.