Java8 Map computeIfAbsent方法说明

// 方法定义
default V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
    ...
}

// java8之前。从map中根据key获取value操作可能会有下面的操作
Object key = map.get("key");
if (key == null) {
    key = new Object();
    map.put("key", key);
}
原文地址:https://www.cnblogs.com/shix0909/p/12207428.html