Here you can find the source of addToMap(Map
public static <K, V> Map<K, V> addToMap(Map<K, V> map, K key, V value)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; public class Main { public static <K, V> Map<K, V> addToMap(Map<K, V> map, K key, V value) { if (key == null) return map; if (map == null) map = new HashMap<K, V>(); map.put(key, value);// w w w . j a v a 2 s. c om return map; } }