Autoboxing And Unboxing

Autoboxing is the automatic conversion of a primitive data type to an object of the cor- responding wrapper class (you box the primitive value). Unboxing is the reverse process (you unbox the primitive value).

Wrapper classes are immutable. Adding a primitive value to a wrapper class variable doesn’t modify the value of the object it refers to. The wrapper class variable is assigned a new object.

Unboxing a wrapper reference variable, which refers to null, will throw a NullPointerException.

Last updated