Code: Select all
Map<String, Integer> map1 = new HashMap<>();
map1.put("a", 1);
map1.put("b", 1);
map1.merge("b", 1, (i1, i2)->i1+i2);
map1.merge("c", 3, (i1, i2)->i1+i2);
System.out.println(map1);
However, running the code results in:
No hint in the documentation either as to why it would throw NPE in this case.{a=1, b=2, c=3}