Pages

Tuesday, September 25, 2012

Autoboxing and Unboxing in Java


The Autoboxing and Unboxing  was released with the Java 5.

Autoboxing
During assignment, the automatic transformation of primitive  type(int, float, double etc.) into their object equivalents or wrapper type(Integer, Float, Double,etc) is known as Autoboxing.

During assignment or calling of constructor, the automatic transformation of wrapper types into their primitive equivalent  is known as Unboxing. Here is a quick video that will explain you the same.


Conversion of int into Integer

int inactive = 0;
inactive = new Integer(5); //auto - unboxing
Integer intObject = 5; //autoboxing

No comments:

Post a Comment