First, the basic data type of java.
Java Basic data type:BYTE, short, int, long, float, double, char, Boolean
Automatic boxing (autoboxing), unpacking (unboxing) of the basic data type is a feature that has been available since J2SE 5.0.
Packing:The basic types are packaged with their corresponding reference types, making them the object's nature. int is packaged as Integer, float is packed into float
Unpacking:As opposed to boxing, simplifying objects of reference types to data of value types
Description:
Equals () compares the values (contents) of two objects. The implementation of equals for different types of objects is different.
"= =" compares the two-object reference (memory address) with the same, and is used to compare the values of variables of two base data types for equality.
Java Wrapper cache scope
//number outside the -128~127
Integer i1 = n;
Integer i2 = n;
System.out.println ("I1==i2:" + (I1==I2));
//number within the -128~127
Integer i3 = +;
Integer i4 = +;
System.out.println ("I3==i4:" + (I3==I4));
The result of the output is:
I1==i2:false
i3==i4:true
In the case of automatic boxing, when values from –128 to 127 are boxed into an integer object, they are reused in memory, so in the example, i3 and I4 actually refer to the same object.
If the value from –128 to 127 is exceeded, the boxed integer object is not reused, which is equivalent to creating a new integer object each time it is boxed, so in the example, I1 and I2 refer to different objects.
In addition, when the auto-boxing function is not used, as in the case of ordinary class objects, consider the following example:
integer i3 = new Integer (+);
integer i4 = new Integer (+);
System.out.println ("I3==i4:" + (I3==I4));//Display False
Java uses this mechanism to minimize the data input and output, which is an optimization measure to improve efficiency. Wrapper Cache Range:
Boolean: (full cache)
Byte: (Cache All)
Character (<=127 Cache)
Integer ( -128~127 Cache)
Short ( -128~127 cache)
Long ( -128~127 Cache)
Float (no cache)
Doulbe (no cache)
JAVAP is a Java-built tool that can be recompiled or viewed by Java compiler-generated bytecode.
Anti-PostScript code meaning, can view http://cooldatabase.iteye.com/blog/637797
Java Boxing, unpacking wrapper