Autoboxing an autounboxing in genral

AutoBoxing and unboxing are features added in Java 5 to work with primitive data types and their corresponding wrapper classes. They are implemented completely in the compiler

Note the amount of code needed just to add two int values. Wrapping/unwrapping an int value to an Integer and vice versa is just a pain for Java developers. Java designers realized it (though too late) and they automated this wrapping and unwrapping process for you.

The automatic wrapping from a primitive data type (byte, short, int, long, float, double, char and boolean) to its corresponding wrapper object (Byte, Integer, Long, Float, Double, Character and Boolean) is called autoboxingThe reverse, unwrapping from wrapper object to its corresponding primitive data type, is called unboxing.


Tip Autoboxing/unboxing is performed when you compile the code. The JVM is completely unaware of the boxing and unboxing performed by the compiler.

原文地址:https://www.cnblogs.com/glf2046/p/4885417.html