I have an ArrayList, a Collection class of Java, as follows:
ArrayList
ArrayList animals = new ArrayList(); animals.add(\"bat\
Map hm = new HashMap(); for(String i : animals) { Integer j = hm.get(i); hm.put(i,(j==null ? 1 : j+1)); } for(Map.Entry val : hm.entrySet()) { System.out.println(val.getKey()+" occurs : "+val.getValue()+" times"); }