Java: use Enumeration several times

I work with DefaultMutableTreeNode, and it has methods depthFirstEnumeration(), breadthFirstEnumeration()and children()that return Enumerationtree nodes.

I need to use the returned Enumerationmultiple times, but I cannot find any method, for example reset()in Enumeration. It seems that I can only get all the elements only once, and then call again depthFirstEnumeration()to get a new one Enumeration, it seems, this is not a good solution.

Of course, I can get all the elements from Enumerationand convert it to any other reusable representation, but is there a way to use it Enumerationseveral times?

+3
source share
1 answer

, Enumeration. java doc :

, Enumeration, , .

, , Enumeration , . Enumeration. , , .

Enumeration e = ...
ArrayList aList = Collections.list(e);
+5

All Articles