boxing

The automatic conversion between a primitive, such as int, and its wrapper object, such as Integer, which the compiler inserts for you.

In more detail

Assigning 42 to an Integer boxes it; assigning an Integer to an int unboxes it. The convenience has costs: boxing creates objects, and unboxing a null reference throws NullPointerException at runtime.

Example

Integer boxed = 42;  int unboxed = boxed;

Related terms

Taught in

References

Certification courses