What is Autoboxing and Unboxing in Java?
Answers
Answered by
0
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
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:
- It helps in writing simpler and efficient codes.
- It allows usage of wapper class object and the primitive data types .
hope its helpfull..
Similar questions
Social Sciences,
4 months ago
Computer Science,
4 months ago
Science,
4 months ago
CBSE BOARD XII,
8 months ago
English,
8 months ago
Math,
1 year ago
Science,
1 year ago