What is the result of the following code?
3: Map<Integer, Integer> map = new HashMap<>(10); 4: for (int i = 1; i <= 10; i++) { 5: map.put(i, i * i); 6: } 7: System.out.println(map.get(4));
A.
Line 3 uses the diamond operator to create the map.
Lines 5 and 7 use autoboxing to convert between the int primitive and the Integer wrapper class.
The keys map to their squared value.
1 maps to 1, 2 maps to 4, 3 maps to 9, 4 maps to 16, and so on.