dcsimg

What does autoboxing and unboxing mean?

John Zukowski

Autoboxing is not casting. Instead, it is the automatic conversion of a primitive data type to its wrapped Object type (boxing) and back (unboxing). For instance, Integer i = 3;, used to generate a compile-time error, now it doesn't, automatically converting the int type 3 to an Integer.