Searching for "unboxing"

Q:

What is autoboxing and unboxing ?

Answer

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. 

Report Error

View answer Workspace Report Error Discuss

Subject: Java

Q:

What is Auto boxing and unboxing?

Answer

Autoboxing is the process of converting a primitive type data into its corresponding wrapper class object instance.


Example:


Integer number = new Integer (100); // number is now refers to the object 100


 


Unboxing is the process of converting a wrapper instance into a primitive type.


Example: 


Integer number = new Integer (100); 


int num = number;// without type casting number would be changed into int type

Report Error

View answer Workspace Report Error Discuss

Subject: Java