Learning: http://www.cnblogs.com/dolphin0520/p/3780005.html#3163302
After discovering that there is such a thing, of course, will not pay attention to what the automatic unpacking and boxing, only know the use of the line. But it's worth noting here that the automatic valueof implementation of an integer is scoped:
When you create an integer object by using the ValueOf method, if the value is between [-128,127], a reference to the object that already exists in Integercache.cache is returned, otherwise a new integer object is created.
Nothing else would have happened. So take a look at a few tests:
Public Static voidMain (string[] args) {Integer i1= 100; Integer I2= 100; Integer i3= 200; Integer I4= 200; System.out.println ("=======integer============"); System.out.println (I1==i2); SYSTEM.OUT.PRINTLN (i3==I4); System.out.println ("=======double============"); Double D1= 12.0; Double D2= 12.0; Double m=123456.12; Double N= 123456.12; DoubleD3 = 12.0; System.out.println (M==N); System.out.println (D1==D2); System.out.println (D1==D3); System.out.println ("=======string============"); String a= "123"; String b= "123"; System.out.println (A==b); System.out.println (A.equals (b)); }
=======integer============truefalse=======double============ false True=======string============truetrue
Java Fundamentals--equality