Here you can find the source of put(Map
public static <K, V> Map<K, V> put(Map<K, V> map, K key, V value)
//package com.java2s; //License from project: Apache License import java.util.Map; public class Main { public static <K, V> Map<K, V> put(Map<K, V> map, K key, V value) { V valueOld = map.get(key);/*ww w . j av a2s . c o m*/ if (valueOld == null) { map.put(key, value); } return map; } }