Reputation: 2545
How can I get the size of an Enumeration<String>
without iterate over it?
While debugging I can see the size
of the the enumeration but I can't find a way to get this value.
Upvotes: 14
Views: 12360
Reputation: 3287
You can do Collections.list(enumerationObject).size();
to get the number of elements.
Upvotes: 9
Reputation: 311853
The Enumeration
interface does not expose its size, and some (many?) implementations indeed do not have this knowledge. Without any knowledge of the specific implementation, you have no choice but to iterate over it.
Upvotes: 9