DEV Community

Cover image for Difference Between Wrapper Class and Wrapper Object
Kalyani Badisha
Kalyani Badisha

Posted on

Difference Between Wrapper Class and Wrapper Object

Wrapper Class:-
A wrapper class is a predefined class in Java that wraps (converts) a primitive data type into an object.

Like int to Integerprimitive data types are can not move in the internet, wrapper classes are freely move in the internet, so the primitive data types are converted into wrapper classes to move in the internet easily.
Example:

Integer i;   // Integer is a wrapper class

Enter fullscreen mode Exit fullscreen mode

Wrapper Object:-
A wrapper object is an instance of a wrapper class that actually stores the primitive value.

Wrapper object is used to store the values of the wrapper classes and the initialization is done in the same time only like

Integer i = 10; // wrapper object created
Enter fullscreen mode Exit fullscreen mode

Example:

Integer i = Integer.valueOf(10); // wrapper object
Enter fullscreen mode Exit fullscreen mode

Overview:
Wrapper class is a predefined class that converts a primitive into an object,
while a wrapper object is the actual instance of that class holding the primitive value.

Top comments (0)