Author: gnuhpc
Source: http://www.cnblogs.com/gnuhpc/
Import Java. util. arraylist; public class autoboxing {public static void main (string [] ARGs) {// manually packed to solve the problem that the container class cannot place basic data types integer intvalue = new INTEGER (1 ); // The encapsulation class is a reference type. The stack stores references. The actual values of double doublevalue = new double (0.5) and float floatvalue = new float (1.1f) are stored on the stack ); int intvar = intvalue. intvalue (); // The basic data type is double doublevar = doublevalue that is directly stored on the stack. doublevalue (); float floatvar = floatvalue. floatvalue (); System. Out. println (intvar + "" + doublevar + "" + floatvar); arraylist <integer> arr = new arraylist <integer> (); arr. add (intvalue); arr. add (1); // automatic packaging to convert the basic data type to the packaging class. Int A = arr. get (0); // automatically unpacks integer I = 2; // automatically packs int B = I + 2; // automatically unpacks integer c = B + 2; // automatically package system. out. println (B) ;}} I noticed that in specification, if the value p being boxed is true, false, a byte, a char in the range/u0000 to/u007f, or an int or short number between-128 and 127, then let R1 and R2 bethe results of any two boxing conversions of P. it is always the case that R1 = R2. that is to say, these two values are R1 = R2. The total return value is true.
Author: gnuhpc
Source: http://www.cnblogs.com/gnuhpc/