Here you can find the source of put(Map
public static <K, V> V put(Map<K, V> aMap, K aKey, V aValue)
//package com.java2s; import java.util.*; public class Main { /**//from ww w. j a v a 2s. c o m * Adds given key and value to given map (removes key if value is null). */ public static <K, V> V put(Map<K, V> aMap, K aKey, V aValue) { if (aValue == null) return aMap.remove(aKey); return aMap.put(aKey, aValue); } }