When is it useful to work with the Java class Enumeration
and why is it useful to work with it?
Asked
Active
Viewed 231 times
4

Basil Bourque
- 303,325
- 100
- 852
- 1,154

John Doe
- 259
- 1
- 6
- 18
-
I think you can see this answer: http://stackoverflow.com/questions/4709175/what-are-enums-and-why-are-they-useful – Zxcv Sep 14 '15 at 20:12
-
2Enumeration is useful if you are using Java 1.0 or 1.1 or an API which was written for these version. – Peter Lawrey Sep 14 '15 at 20:28
-
when - last century :) – ZhongYu Sep 14 '15 at 22:46
1 Answers
6
Enumeration
is largely obsolete. Per the Javadoc, it is an interface that generates a series of elements, one at a time. Successive calls to the nextElement
method return successive elements of the series. It is the predecessor to Iterator
which (per the Javadoc)
Iterator
takes the place ofEnumeration
in the Java Collections Framework.

Elliott Frisch
- 198,278
- 20
- 158
- 249
-
2
-
1@PeterLawrey Which is also when Collection(s) were added. Apache Commons Collections provides [`EnumerationIterator`](http://commons.apache.org/proper/commons-collections/javadocs/api-3.2.1/org/apache/commons/collections/iterators/EnumerationIterator.html) which can be used to make an `Enumeration` appear as an `Iterator`. – Elliott Frisch Sep 14 '15 at 20:34
-