In some wrapper objects, such as Integer, if the return value obtained by comparing "= =" between range 128 to 127 is true, then they return the same object, but not in this range. This behavior is usually more dependent on the JVM, so it is best to use the Equals () method to avoid using "= =" when checking.
Example:
Integer i1 = (i1 = = i2) System.out.println ("equal"); Else System.out.println ("unequal");
The result is "not equal". Because in this case, the automatic unpacking is not executed. The literal value of "200" is boxed in two different integer objects (different JVM results may vary), then the objects are compared by "= =" and the result is false because the two objects are different instances and have different memory addresses.
Integer i1=[+]if (i1 = = i2) System.out.println ("equal"); Else System.out.println ("unequal");
The result is "equal" at this time. Because the value of int is within the range of 127 to 127, the JVM caches the value, so "= =" returns the result of true.
Problems with automatic boxing