更新时间:2023-11-27 09:59:28
使用computeIfAbsent:
computeIfAbsent
map.computeIfAbsent(work, k -> new ArrayList<>()).add("aaa");
如果列表中不存在新列表,则会将其存储在地图中,并返回新列表或现有列表.
Which stores a new list in the map if it does not already exist and returns the new or existing list.
java8映射如何简单地将一些元素添加到列表值