Java automatic packing and unpacking
Autoboxing and unboxing of the Primitive type are new functions provided by J2SE 5.0, which are the same as generic and variable-length parameters, this is also a "syntactic Sugar". As mentioned earlier in the introduction of jvm optimization, syntactic sugar has no impact on the code in the runtime, and its purpose is only to facilitate the use by programmers, after compilation, all syntactic sugar will be restored to the basic syntax. The automatic packing and unpacking introduced this time are no exception. See the following example:
public class Demo{public static void main(String[] args){Integer i = 3;int j = i;}}
This is the so-called packing and unpacking. Next we will look at its true nature through decompilation:
<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KCr/J0tS/tLW917DP5LLZ1/tests/d2uWjrNfutPO1xL/tests + tests/gtci1xKOss6y5/tests = "brush: java;"> Integer I = 128; integer j = 128; System. out. println (I = j); // falseInteger i2 = 127; Integer j2 = 127; System. out. println (i2 = j2); // true