PrepZone Logo
PrepZone
Back to Java

Java · Easy

What is autoboxing and unboxing in Java? Provide examples.

JavaCore Java

Answer preview

Autoboxing — Automatic conversion of a primitive type to its corresponding wrapper class by the compiler. Example: Integer x = 42; — the compiler converts int 42 to Integer.valueOf(42).…