PackageCom.ilaw.boson.controller; Public classDemo { Public Static voidMain (string[] args) {Integer a=NewInteger (2000); intb =2000; Integer C=b; System.out.println (A= = b);//when True,integer and int are operated, a is removed from the boxSystem.out.println (b = = c);//when True,integer and int are operating, C is unboxingSystem.out.println (A = = c);//when the false,b is assigned, boxing calls the Integer.valueof method to box aa=NewInteger (10); C=10; System.out.println (A= = c);//false, the Integer.valueof method is called when a row boxing operation is performed, essentially two object comparisonsa=10; System.out.println (A= = c);//true, two objects are constructed by boxing, that is, through the Integer.valueof method, if the value is between 128-127, it is taken from the Integercache /*** Summary: * 1.Integer and int operations, the integer object is unboxing * 2. The address of an integer object is created differently by the new method * 3. Through in Teger a=10; The way the value is assigned will be boxed, boxing will call the integer valueof method * 4.Integer internally through the Integercache object to store the commonly used-128-127 integer object, when boxing will return in Tegerchache's Object **/ //description, when the integer type and int type are manipulated (equal, added), the unboxing operation is performed }}
Summarize:
When the 1.Integer and int are operating, the integer object is handled as a unboxing
2. When you create an address for an integer object by using the new method, different
3. When you assign a value by using an integer a=10, it will be boxed and the valueof method of the integer will be called.
The Integercache object is used internally by the 4.Integer to store an integer object between the common-128-127, which returns the Integerchache object when it is boxed.
Java integer classes and unpacking and boxing