Here you can find the source of incrementTwoLevelHashMap(HashMap map, String key1, String key2, int n)
public static void incrementTwoLevelHashMap(HashMap map, String key1, String key2, int n)
//package com.java2s; //License from project: Apache License import java.util.HashMap; public class Main { public static void incrementTwoLevelHashMap(HashMap map, String key1, String key2, int n) { HashMap map2 = (HashMap) map.get(key1); if (map2 == null) { map2 = new HashMap(); map.put(key1, map2);//from ww w .j a va 2 s .co m } incrementHashMap(map2, key2, n); } public static void incrementHashMap(HashMap map, String key, int n) { int count; Integer countI = (Integer) map.get(key); if (countI == null) count = 0; else { count = countI; } map.put(key, count + n); } }