Wrapper Class

A wrapper class is a class whose object wraps or contains primitive data types. When we create an object to a wrapper class, it contains a field and in this field, we can store primitive data types. In other words, we can wrap a primitive value into a wrapper class object.

They provide a way to use primitive data types as objects. These classes encapsulate a primitive data type within them, and provide a mechanism to ‘wrap’ the primitive values in an object.

Some examples of wrapper classes are Integer, Long, Boolean, etc. These are all classes present in the java.lang package which provide certain methods for the base types. This is part of Java's mechanism of 'Autoboxing and Unboxing'.