I have an ArrayList, a Collection class of Java, as follows:
ArrayList
ArrayList animals = new ArrayList(); animals.add(\"bat\
In Java 8:
Map counts = list.stream().collect(Collectors.groupingBy(e -> e, Collectors.counting()));