what is the difference between Iterator and Enumeration
Printable View
what is the difference between Iterator and Enumeration
Could you copy and paste the the API doc for those two classes as a starting point?
Quote:
Enumeration: An object that implements the Enumeration interface generates a series of elements, one at a time. Successive calls to the nextElement method return successive elements of the series.
I suggest you use an Iterator.Quote:
Iterator: An iterator over a collection. Iterator takes the place of Enumeration in the Java collections framework. Iterators differ from enumerations in two ways:
Iterators allow the caller to remove elements from the underlying collection during the iteration with well-defined semantics.
Method names have been improved.
There you go.
using Enumeration one can Iterate over a Collection of elements.
Iterator is same like that but able to delete the elements from the Collection.