Java Map Put putIfNotExist(Map map, K key, V value)

Here you can find the source of putIfNotExist(Map map, K key, V value)

Description

put If Not Exist

License

Open Source License

Declaration

public static <K, V> void putIfNotExist(Map<K, V> map, K key, V value) 

Method Source Code

//package com.java2s;

import java.util.Map;

public class Main {
    public static <K, V> void putIfNotExist(Map<K, V> map, K key, V value) {
        if (!map.containsKey(key)) {
            map.put(key, value);/*from  w ww  .j a va2 s  .  c o m*/
        }
    }
}

Related

  1. putIfAbsent(Map map, K key, V value)
  2. putIfAbsent(Map map, S key, T val)
  3. putIfAbsent(Map map, String name, String value)
  4. putIfAbsentGet(Map map, K key, V value)
  5. putIfNonNull(Map map, K key, V value)
  6. putIfNotExists(final K key, final V value, final Map map)
  7. putIfNotExists(Map map, K key, V value)
  8. putIfNotNull(final Map map, final String name, final String value)
  9. putIfNotNull(Map map, K key, V value)