Enumeration and Iterator are the interface available in java.util package. Enumeration contains 2 methods namely hasMoreElements() & nextElement().
Iterator contains three methods namely hasNext(), next(),remove(). Using remove() we can also delete the objects but Enumeration interface does not support this feature.
Above answer was rated as good by the following members: janmaijais
RE: Tell me the differences between enumeration and it...
Enumeration deals with objects while iteration deals with values only. Enumeration is used when we use vector hashtable etc while iteration are used in while loop for loop etc
RE: Tell me the differences between enumeration and it...
Hi !
Both will help you to travel into collection bag But Enumeration is a leagsy classes and it comes with java1.1 Iterater they have introduced in Collection framework.
In enumeration we can modify the collection objects but throw Iterator it is possible.
RE: Tell me the differences between enumeration and it...
Enumerator and Iterator are almost same.But in Iterator there is one extra method called remove .and iterator is part of the new collection class.Java API says to use more of iterator than Enumerator which is kind of old class.
RE: Tell me the differences between enumeration and it...
Enumeration and Iterator both are interfaces present in util package. Enumeration is a legacy interface which does not come under the collection framework wheras Iterator is an interface present in the collection framework. All the legacy classes like Stack Vector Hashtable Properties can use Enumeration for enumerating the elements from the collection. The classes under the collection framework like ArrayList LinkedList HashSet Tree Set etc can use the Iterator interface
RE: Tell me the differences between enumeration and it...
Both are used to travel objects one by one But Enumeration is a leagsy classes and it comes with java1.1 Iterater they have introduced in Collection framework.
Enumeration can be used for Collection objects as well as Iterator can be used for legacy classes.
Enumeration acts as Read-only interface because it has the methods only to travels and fetch the objects where as using Iterator we can manipulate the objects also like adding and removing the objects.
So Enumeration is used when ever we want to make Collection objects as Read-only.