CAN YOU EXPLAIN ABOUT AUTOBOXING AND UNBOXING IN JAVA ?

Mayank Tripathi

Total Post:807

Points:4035
Posted by  Mayank Tripathi
Java 
 551  View(s)
Ratings:
Rate this:
  1. Mayank Tripathi

    Post:807

    Points:4035
    Can you explain about autoboxing and unboxing in Java ?

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!