0% found this document useful (0 votes)
6 views3 pages

Boxing Andautngo Box

Autoboxing is the automatic conversion between primitive types and their corresponding object wrapper classes in Java, while unboxing is the reverse process. This feature, introduced in Java 5, allows for cleaner code as developers can use primitive types and wrapper class objects interchangeably without explicit typecasting. The main difference is that boxing converts value types to object types, whereas unboxing converts object types back to value types.

Uploaded by

Sunil
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)
6 views3 pages

Boxing Andautngo Box

Autoboxing is the automatic conversion between primitive types and their corresponding object wrapper classes in Java, while unboxing is the reverse process. This feature, introduced in Java 5, allows for cleaner code as developers can use primitive types and wrapper class objects interchangeably without explicit typecasting. The main difference is that boxing converts value types to object types, whereas unboxing converts object types back to value types.

Uploaded by

Sunil
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/ 3

Autoboxing is the automatic conversion that the Java compiler makes between the primitive

types and their corresponding object wrapper classes. For example, converting an int to an
Integer, a double to a Double, and so on. If the conversion goes the other way, this is called
unboxing.
Autoboxing and boxing are one and the same.
Unboxing is the reverse of boxing.

.parse-String to primitive datatype


.valueOf-String to primitive datatype
Both .parse and .valueOf are one and the same.
.toString()-

boxing/Auto boxing: int to an Integer(Primitive to Wrapper)


Unboxing :Wrapper class to Wrapper class/Primitive datatype to Primitive data type

unboxing is the conversion from the wrapper class to the primitive data type.
BoXing
..
Advantages of Autoboxing / Unboxing:
 Autoboxing and unboxing lets developers write cleaner code, making it easier to read.
 The technique let us use primitive types and Wrapper class objects interchangeably and
we do not need to perform any typecasting explicitly.

The basic difference between Boxing and Unboxing is that Boxing is the conversion of the
value type to an object type whereas, on other hands, the term Unboxing refers to the
conversion of the object type to the value type. Answer: Unboxing is the conversion form the
wrapper class to the primitive data type.

Wrapper classes in java provides a


mechanism to convert primitive into object
and object into primitive. Whereas automatic
boxing and unboxing allows you to do that
conversion automatically. Autoboxing and
auto unboxing are legal in java since Java 5.

You might also like