Autoboxing and Unboxing

Learn about autoboxing and unboxing.

We'll cover the following...

What is autoboxing?

Autoboxing is an automatic conversion from the primitive types to their corresponding object wrapper classes. It includes converting an int to an Integer and a double to a Double.

Autoboxing is applied when:

  • A primitive value is passed as an argument to a method that expects an object of the corresponding wrapper class.
  • A primitive value is assigned to a variable of the corresponding wrapper class.

Here’s ...