I know there are similar posts on the topic, but they don\'t quite address my question. When you do:
Integer a = 10;
Integer b = 10;
System.out.println(\"a =
This would potentially break code written before this design change, when everybody righfully assumed that two newly created instances were different instances. It could be done for autoboxing, because autoboxing didn't exist before, but changing the meaning of new is too dangerous, and probably doesn't bring much gain. The cost of short-lived objects is not big in Java, and could even be lower than the cost of maintaining a cache of long-lived objects.