Search⌘ K

Autoboxing and Unboxing

Explore autoboxing and unboxing concepts in Java which automatically convert between primitive types and their wrapper classes. This lesson helps you understand how these conversions simplify coding and method interactions.

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 an ...