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

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure