Java Wrapper Class & Boxing, Unboxing

A Wrapper Class in Java wraps primitive type and provides member methods around it. We call the process of wrapping as Boxing and reverse of it as Unboxing. With the use of a Wrapper Class we can see a primitive type as an object. Java collections do not support primitive types. But it can store objects. So, to store primitive types in a collection we can wrap it using a wrapper class. After wrapping a primitive using wrapper, we can use the member methods of the wrappers which act on the primitive type. The examples are:
Converting a double value to string.
Converting an integer to a long type.
We can also get back the primitive type from its wrapper. This is called Unboxing. In this article, we will see the examples to get better in sight on the Boxing and Unboxing.