how to count the number of occurrences of an element in a arraylist in java
ArrayList<String> listName = new ArrayList<>();
int occurrences = Collections.frequency(listName, "element");
5
1
int occurrences = Collections.frequency(animals, "bat");
Thank you!
1
0
Are there any code examples left?
New code examples in category Java