Tuesday, November 29, 2011

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.

The functionality of Enumeration interface is duplicated by the Iterator interface. In addition, Iterator adds an optional remove operation, and has shorter method names :1. Difference between Enumeration and Iterator interface is Enumeration has two methods hasMoreElements() and nextElement() and Iterator has three methods hasNext() and next() and remove().:1. if i want to write a method for traversing through a collection.
Category:Java Interview Questions

No comments:

Post a Comment