Computer Science, asked by shivam3610, 5 months ago

What is Autoboxing and Unboxing in Java?​

Answers

Answered by Anonymous
0

\huge{\underline{\boxed{\sf{\red{\mathfrak{Answer-}}}}}}

When Java automatically converts a primitive type into corresponding wrapper class object e.g., int into Integer, then its called autoboxing because primitive is boxed into wrapper class while opposite case is called unboxing, where an integer object is converted into primitive int.

Since the whole process happens automatically without writing any code for conversion it is called autoboxing and auto-unboxing.

━━━━━━━━━━━━━━━━━━━━━━━

Answered by kavitasingh1234
2

Answer:

Autoboxing:-

The conversion of primitive data types into wrapper class is called Autoboxing.

Unboxing:-

The conversation of wrapper class objects to its corresponding primitive data type is called Unboxing.

Example:

Integer in=new Integer(674);

The syntax to unbox the object

int a=in;

Advantages of Autoboxing and Unboxing are:

  1. It helps in writing simpler and efficient codes.
  2. It allows usage of wapper class object and the primitive data types .

hope its helpfull..

Similar questions