For example, say I have an ArrayList
that could contain the following values:
x
x
x
y
y
Now what I want to retrieve is the number
Check out the Multiset in google guava: http://docs.guava-libraries.googlecode.com/git-history/v11.0.2/javadoc/com/google/common/collect/Multiset.html
Example:
Multiset strings = HashMultiset.create(arrayList);
int countX = strings.count("x"); // the count of x
More examples can be found on the Guava wiki.