Here you can find the source of incrementMap(HashMap
public static void incrementMap(HashMap<Integer, Integer> map, Integer key)
//package com.java2s; //License from project: Apache License import java.util.HashMap; public class Main { public static void incrementMap(HashMap<Integer, Integer> map, Integer key) { Integer count = map.get(key); if (count == null) { map.put(key, 1);//from ww w . j a v a 2 s.c o m } else { map.put(key, count + 1); } } public static void incrementMap(HashMap<String, Integer> map, String key) { Integer count = map.get(key); if (count == null) { map.put(key, 1); } else { map.put(key, count + 1); } } }