Autoboxing and Unboxing

  • Eclipse: Oxygen
  • Java: 1.8

In this tutorial, we will learn about what is autoboxing and unboxing. The ArrayList is very efficient, as we have seen, but it includes some more interesting features that are seen in this tutorial.

The ArrayList only accepts the elements which are an object to a class such as an Integer class or any user-defined class but not for any primitive data type. Hence if we define the class as an Integer and not any user-defined class then the java automatically simplifies the work to create necessary new objects and the same while getting the value by indexing which we have to manually define while using a user-created class both of which examples are shown.

Output

10.0

Output

10
12.0

Contributed by: Poonam Tomar


VIEW COURSES

Buy me a coffee!

 

PayTM QR (INDIA)

  • Get video tutorials
  • Project files set
  • Get┬áCertified

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu