Question 14
Back to Exercise
What does groups.computeIfAbsent(k, x -> new ArrayList<>()).add(v) do?
- A Replaces the list each time
- B Creates a list the first time k is seen and adds v to the list for k Correct
- C Throws if k exists
- D Adds k to every list
Correct Answer: Option B
computeIfAbsent returns the existing or newly created value.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!