What is the difference between Enumeration and Iterator?. When i can use Enumeration and when i can use iterator?. Can any one tell me the situation that only Enumeration could able to solve that problem and vice versa.

In Enumeration we cant modify the elements. where as in iterator we can modify the elements

Questions by antony_praveen80   answers by antony_praveen80

Showing Answers 1 - 10 of 10 Answers

The functionality of Enumeration  interface is duplicated by the Iterator interface. In addition, Iterator adds an optional remove operation, and has shorter method names

  Was this answer useful?  Yes

Praveen

  • Sep 29th, 2005
 

Hi Bhavin Mehta,

  Can u make it little bit clear. I am not getting your answer.

  Was this answer useful?  Yes

sangeeta

  • Oct 3rd, 2005
 

1 more difference between Enumeration and Iterator is that Iterator has a remove() method while Enumeration doesn't.

  Was this answer useful?  Yes

Mahantesh V Kabadagi

  • Jul 13th, 2006
 

Both are used to traverse objects one by one, But Enumeration is a legacy 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 traverse 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.

  Was this answer useful?  Yes

Both are used to traverse objects one by one but Enumeration is a legacy 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 traverse 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.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions