I created the following method that adds the given UUID value with the given Integer to teh map
variable.
final Map<Integer, List<UUID>> map = new TreeMap<>();
private void addToMap(Integer key, UUID value) {
map.computeIfAbsent(key, val -> new ArrayList<>()).add(value);
}
Normally I was tried to use map.computeIfAbsent(key, value -> new ArrayList<>()).add(value);
by passing value
parameter to the lambda function, it it throws "Variable 'value' is already defined in the scope" error pointing the "value" in .. value -> ...
part.
My updated addToMap
method is working, but I think val
is pointless. So, how should this method be updated?