हिंदी

Write a difference between Autoboxing and Unboxing.

Advertisements
Advertisements

प्रश्न

Write a difference between Autoboxing and Unboxing.

अंतर स्पष्ट करें
Advertisements

उत्तर

Feature Autoboxing Unboxing
Definition Converts a primitive type into its corresponding wrapper class object. Converts a wrapper class object back into its primitive type.
Direction Primitive → Object (e.g., int to Integer). Object → Primitive (e.g., Integer to int).
Java Example Integer obj = 25; int num = obj;
Behind the Scenes Java uses Integer.valueOf(25) under the hood. Java uses obj.intValue() under the hood.
Common Use Case When adding primitive numbers into collections like an ArrayList When performing mathematical operations on values stored inside objects.
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 5: Library Classes - Exercises [पृष्ठ १३४]

APPEARS IN

रुपा पंडित Computer Applications [English] Class 10 ICSE
अध्याय 5 Library Classes
Exercises | Q 4. (v) | पृष्ठ १३४
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×