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