Ami Hollander
Ami Hollander

Reputation: 2545

Size of Enumeration<String>

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

Answers (2)

psv
psv

Reputation: 3287

You can do Collections.list(enumerationObject).size(); to get the number of elements.

Upvotes: 9

Mureinik
Mureinik

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

Related Questions