AP® Computer Science A glossary
Unboxing
Course: AP® Computer Science A Shows up in: Unit 4: Data Collections
The automatic conversion the compiler makes from a wrapper class object to its primitive value, such as Integer to int or Double to double.
Appears in the course and exam description (CED): 4.7.A.3
It happens when a wrapper object is assigned to a variable of the primitive type, or passed to a parameter of that primitive type. Unboxing null throws a NullPointerException.
Integer stored = 12;
int plain = stored;
System.out.println(plain * 2);
Output:
24 Learn it properly, with a checkpoint 4.7 Wrapper Classes