January 2018
Intermediate to advanced
115 pages
1h 37m
English
Placing a primitive variable in an object is known as boxing. Boxing allows the primitive to be used where objects are required. For this purpose, Java provides wrapper classes to implement boxing for each primitive type —namely, Byte, Short, Integer, Long, Float, Double, Character, and Boolean. An Integer object , for example, can hold a variable of the type int:
The opposite of boxing is, naturally, unboxing, which converts the object type back into its primitive type: