Home > DeveloperSection > Interviews > Can you explain about autoboxing and unboxing in Java ?

Posted on    July-13-2015 12:36 AM

 Java Java 
 1 Answer(s)
  349  View(s)
Rate this:

Mayank Tripathi
Mayank Tripathi

Total Post:807

Posted on    July-13-2015 12:36 AM

When primitive data types are automatically converted into it's  wrapper type, it is called boxing. The opposite operation of converting wrapper class objects to it's primitive type is known as unboxing.
ArrayList<Integer> list = new ArrayList<Integer>();
list.add(1); //autoboxing - primitive to object
int number = list.get(0); // unboxing

Don't want to miss updates? Please click the below button!

Follow MindStick