My Tech Notes
Search This Blog
Java: How to count the number of ocurrences of an element in a Collection
Java 6 Collections has a static method:
frequency(Collection<?> c, Object o)
:
int numOccurs = Collections.frequency(list, elem);
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment