I have a class that implements the Enumeration<T>
interface, but Java's foreach loop requires the Iterator<T>
interface. Is there an Enumeration
to Iterator
Adapter in Java's standard library?
If you just want something to iterate over in a for-each loop (so an Iterable and not only an Iterator), there's always java.util.Collections.list(Enumeration<T> e)
(without using any external libraries).