// 方法定义
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);
}
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄