Showing posts from November 27, 2010

autoboxing and unboxing in java

autoboxing and unboxing in java –

autoboxing and unboxing concepts is related to primitive data types and its wrapper classes. If any wrapper class holds the value of its primitive data type called boxing. And if any primitive data type holds the objects of its wrapper class called unboxing.

autoboxing and unboxing in java is two types :
1) Implicit Auto boxing.
2) Explicit boxing.
3) Implicit unboxing.
4) Explicit unboxing.

Implicit Auto boxing –

J2SE 5 was added autoboxing. Autoboxing is internal process where primitive data type automatically encapsulated within their wrapper classes. So there is no need to wrap primitive data type to its wrapper classes. There is really very helpful with in collection framework. Because collections framework allows objects instead of primitive data type.

Example :-

Integer intObj = 786; // Autoboxing
List listObj = new ArrayList();
listObj.add(786); // Autoboxing
listObj.add(787); // Autoboxing

So in this line there is no need to make an object and the…

Recent Post

Recent Posts Widget