I’m pretty sure the static frequency-method in Collections would come in handy here:
int occurrences = Collections.frequency(animals, "bat");
That’s how I’d do it anyway. I’m pretty sure this is jdk 1.6 straight up.
More Related Contents:
- When to use LinkedList over ArrayList in Java?
- Initialization of an ArrayList in one line
- How do I remove repeated elements from ArrayList?
- Sorting an ArrayList of objects using a custom sorting order
- Converting ‘ArrayList to ‘String[]’ in Java
- How to sort a List/ArrayList?
- How to find an object in an ArrayList by property
- How to sort an ArrayList in Java [duplicate]
- Which Java Collection should I use?
- How to randomize two ArrayLists in the same fashion?
- How do I make my ArrayList Thread-Safe? Another approach to problem in Java?
- How to sort an ArrayList using multiple sorting criteria?
- Best way to create a hashmap of arraylist
- Add multiple items to an already initialized arraylist in Java
- How to remove element from ArrayList by checking its value?
- Empty an ArrayList or just create a new one and let the old one be garbage collected? [duplicate]
- ArrayList filter [duplicate]
- ArrayList Vs LinkedList
- ArrayList: how does the size increase?
- What is the Simplest Way to Reverse an ArrayList?
- ArrayList vs LinkedList from memory allocation perspective
- Vector vs Collections.synchronizedList(ArrayList)
- Does the capacity of ArrayList decrease when we remove elements?
- How to remove common values from two array lists
- How to sort Arraylist of objects
- Java: how can I split an ArrayList in multiple small ArrayLists?
- Why does ArrayList have “implements List”? [duplicate]
- java.util.Vector – alternatives
- Is there an insertion order preserving Set that also implements List?
- How to declare an ArrayList with values? [duplicate]