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
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
Example:
Integer i = Integer.valueOf(10); // wrapper object
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)