Nuñ*_*ada 5 java collections hashmap java-8
我有这段代码:
if (notificationSend.get(key) != null && notificationSend.get(key).equals(value)) {
return true;
} else {
notificationSend.put(key, value);
return false;
}
Run Code Online (Sandbox Code Playgroud)
我想知道是否有可能使用Jav8增强功能重构它compute(),computeIfPresent()或者computeIfAbsent()
假设value非null,则不需要使用条件或任何这些compute*方法.
ValueType oldValue = map.put(key, value);
return value.equals(oldValue);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
359 次 |
| 最近记录: |