Java – retrieves the number of types in the list
•
Java
I have a list The list can contain multiple items of the same enumeration type
Let's say I have an enumeration: toy is valuable: ball, doll, play I want to know how many Playstation items are in the toy type list (i.e. list < toy >)
What is the best solution? I don't want to iterate through the list every time
Solution
You can use Apache commons collections' hashbag It has a getcount (object) method that suits you
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码