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.
For details visit: http://www.roseindia.net/javatutorials/autoboxing_yourself_in_JDK_1_5.shtml
Conversion of int into Integer
int inactive = 0;
inactive = new Integer(5); //auto - unboxing
Integer intObject = 5; //autoboxing
int inactive = 0;
inactive = new Integer(5); //auto - unboxing
Integer intObject = 5; //autoboxing
No comments:
Post a Comment