Boxing and Unboxing
Placing a primitive variable in an object is known as boxing. This allows the primitive to be used where objects are required. For this purpose Java provides wrapper classes for each primitive – namely: Byte, Short, Integer, Long, Float, Double, Character and Boolean. An Integer object, for example, can hold a variable of the type int.
int iPrimitive = 5;Integer iWrapper = new Integer(iPrimitive); // boxing
The opposite of boxing is unboxing. This converts the object type back into its primitive type.
iPrimitive = iWrapper.intValue(); // unboxing
The wrapper classes belong to the java.lang package, which is always ...