Here you can find the source of putIfNotExists(Map super K, ? super V> map, K key, V value)
@SuppressWarnings("unchecked") static <K, V> V putIfNotExists(Map<? super K, ? super V> map, K key, V value)
//package com.java2s; //License from project: Apache License import java.util.Map; public class Main { @SuppressWarnings("unchecked") static <K, V> V putIfNotExists(Map<? super K, ? super V> map, K key, V value) { if (!map.containsKey(key)) { map.put(key, value);//from www . j a v a 2s .co m } return (V) map.get(key); } }