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