Frequently Used Methods of Java HashMap

HashMap is very useful when a counter is required.

HashMap<String, Integer> countMap = new HashMap<String, Integer>();
 
//.... a lot of a's like the following
if(countMap.keySet().contains(a)){
	countMap.put(a, countMap.get(a)+1);
}else{
	countMap.put(a, 1);
}

Read more