0% found this document useful (0 votes)
2 views1 page

Wrapper Classes

Wrapper classes in Java allow for the conversion between primitive types and objects, facilitating autoboxing and unboxing since J2SE 5.0. They are essential in scenarios such as method value changes, serialization, synchronization, and working with the Java Collections Framework. Wrapper classes enable the use of primitives in contexts that require objects, enhancing Java's object-oriented capabilities.

Uploaded by

ASK 011
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Wrapper Classes

Wrapper classes in Java allow for the conversion between primitive types and objects, facilitating autoboxing and unboxing since J2SE 5.0. They are essential in scenarios such as method value changes, serialization, synchronization, and working with the Java Collections Framework. Wrapper classes enable the use of primitives in contexts that require objects, enhancing Java's object-oriented capabilities.

Uploaded by

ASK 011
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Wrapper classes in Java

The wrapper class in Java provides the mechanism to convert primitive


into object and object into primitive.

Since J2SE 5.0, autoboxing and unboxing feature convert primitives into
objects and objects into primitives automatically.

automatic conversion of primitive into object is known as


autoboxing

automatic conversion of object into primitive is known as


unboxing

Use of Wrapper classes in Java

Java is an object-oriented programming language, so we need to deal with


objects many times like in Collections, Serialization, Synchronization, etc.
Let us see the different scenarios, where we need to use the wrapper
classes.

o Change the value in Method: Java supports only call by value. So, if we
pass a primitive value, it will not change the original value. But, if we
convert the primitive value in an object, it will change the original value.
o Serialization: We need to convert the objects into streams to perform the
serialization. If we have a primitive value, we can convert it in objects
through the wrapper classes.
o Synchronization: Java synchronization works with objects in
Multithreading.
o java.util package: The java.util package provides the utility classes to
deal with objects.
o Collection Framework: Java collection framework works with objects
only. All classes of the collection framework (ArrayList, LinkedList, Vector,
HashSet, LinkedHashSet, TreeSet, PriorityQueue, ArrayDeque, etc.) deal
with objects only.

You might also like