Here you can find the source of addToMapMap(Map
Parameter | Description |
---|---|
map | The map. |
key1 | The outer key. |
key2 | The inner key. |
value | The value. |
public static <K1, K2, V> void addToMapMap(Map<K1, Map<K2, V>> map, K1 key1, K2 key2, V value)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; public class Main { /**/* w w w. j a v a2s .co m*/ * Adds the given key-value mapping to the given map. * @param map The map. * @param key1 The outer key. * @param key2 The inner key. * @param value The value. */ public static <K1, K2, V> void addToMapMap(Map<K1, Map<K2, V>> map, K1 key1, K2 key2, V value) { Map<K2, V> innerMap = map.get(key1); if (innerMap == null) { innerMap = new HashMap<K2, V>(); map.put(key1, innerMap); } innerMap.put(key2, value); } }