I was trying sample code and some got result which I don't understand:
Map<Integer,Integer> map = new HashMap<>();
map.put(1, 2);
System.out.println(map.get(1));
Integer k = map.get(1);
k++;
System.out.println(map.get(1));
The result:
2
2
But as Integer is an object, the change should get reflected in the map value as well? So why is the value not changing?