Autoboxing and Unboxing
Autoboxing and Unboxing
What is Autoboxing and Unboxing ?
Re: Autoboxing and Unboxing
Autoboxing: Converting a primitive value into an object of the corresponding wrapper class is called autoboxing.
For example, converting int to Integer class.
Unboxing: Converting an object of a wrapper type to its corresponding primitive value is called unboxing.
For example conversion of Integer to int.
For example, converting int to Integer class.
Unboxing: Converting an object of a wrapper type to its corresponding primitive value is called unboxing.
For example conversion of Integer to int.
Re: Autoboxing and Unboxing
Autoboxing:
***************
-->Converting a primitive value into an object of the corresponding wrapper class is called autoboxing. For example, converting int to Integer class. The Java compiler applies autoboxing when a primitive value is:
Passed as a parameter to a method that expects an object of the corresponding wrapper class.
Assigned to a variable of the corresponding wrapper class.
Unboxing:
************
-->Converting an object of a wrapper type to its corresponding primitive value is called unboxing. For example conversion of Integer to int. The Java compiler applies unboxing when an object of a wrapper class is:
Passed as a parameter to a method that expects a value of the corresponding primitive type.
Assigned to a variable of the corresponding primitive type.
***************
-->Converting a primitive value into an object of the corresponding wrapper class is called autoboxing. For example, converting int to Integer class. The Java compiler applies autoboxing when a primitive value is:
Passed as a parameter to a method that expects an object of the corresponding wrapper class.
Assigned to a variable of the corresponding wrapper class.
Unboxing:
************
-->Converting an object of a wrapper type to its corresponding primitive value is called unboxing. For example conversion of Integer to int. The Java compiler applies unboxing when an object of a wrapper class is:
Passed as a parameter to a method that expects a value of the corresponding primitive type.
Assigned to a variable of the corresponding primitive type.