Although due to autoboxing, both lines of code lead to the fact that an object Integerwith a value 1is pushed onto the stack, two lines do not have the same effect.
Autoboxing uses the Integer cache that JLS requires for values from -128to 127, so the resulting instance Integeris the same instance for any value in this range.
int Integer , .
:
Integer a = 1;
Integer b = 1;
System.out.println(a == b);
Integer c = new Integer(1);
Integer d = new Integer(1);
System.out.println(c == d);
, == ( ) , / equals().