About Question enthuware.ocpjp.v8.2.1864 :
Posted: Tue Nov 17, 2015 1:21 pm
Answer appears to be wrong for this question:
Quiz says it will throw NullPointerException at runtime
However, running the code results in:
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}