Here:
Integer i = new Integer(10);
Integer i1 = new Integer(10);
you ask for dynamically allocated two instances of Integer class type, this will give you two different references. If you change it to:
Integer i = 10;
Integer i1 = 10;
then reference of i and i1 will be equal because for small values wrapper classes use cached objects.
This:
i++;
i1++;
is explained in: 15.14.2. Postfix Increment Operator ++ in JLS (emphasis mine):
Before the addition, binary numeric promotion (§5.6.2) is performed on the value 1 and the value of the variable. If necessary, the sum is narrowed by a narrowing primitive conversion (§5.1.3) *and/or subjected to boxing conversion (§5.1.7) to the type of the variable before it is stored.
also a note below is important which says that before operator is applied an unboxing conversion may happen:
Note that the binary numeric promotion mentioned above may include unboxing conversion (§5.1.8) and value set conversion (§5.1.13). If necessary, value set conversion is applied to the sum prior to its being stored in the variable.
so it means it is boxed back to the wrapper type
so in the end after applying an operator ++ to either reference type of allocated Integer instance or a boxed Integer class, you end with a boxed Integer if its value is in the correct range for boxed types.