Autoboxing and Unboxing

The Autoboxing and Unboxing  was released with the Java 5.


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.


Integer intObject = 5; // autoboxing


During assignment or calling of constructor, the automatic transformation of wrapper types into their primitive equivalent  is known as Unboxing.

int inative = 0;
inative = new Integer(5); // auto-unboxing

Autoboxing also works with comparison
int a = 10;
Integer b = 10;
System.out.println(a==b); // true

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: