/* Autoboxing The automatic conversion of primitive types to the object of their corresponding wrapper classes is known as autoboxing. For example – conversion of int to Integer, long to Long, double to Double, etc. */ class WC { public static void main(String[] args) { // Primitive data type int b; // Integer wrapper class Integer a; // assigning value to primitive b = 357; // auto-boxing or auto wrapping converting primitive int to Integer object a = b; System.out.println("The primitive int b is: " + b); System.out.println("The Integer object a is: " + a); } } /* They convert primitive data types into objects. Objects are needed if we wish to modify the arguments passed into a method (because primitive types are passed by value). The classes in java.util package handle only objects and hence wrapper classes help in this case. Data structures in the Collection framework, such as ArrayList and Vector, store only objects (reference types) and not primitive types. An object is needed to support synchronization in multithreading. Advantages of Wrapper Classes Collections allow only object data. On object data we can call multiple methods compareTo(), equals(), toString() The cloning process only works on objects Object data allows null values. Serialization allows only object data. */ import java.util.ArrayList; class WC { public static void main(String[] args) { char ch = 'a'; // Autoboxing- primitive to Character object // conversion Character a = ch; ArrayList arrayList = new ArrayList(); // Autoboxing because ArrayList stores only objects arrayList.add(25); // printing the values from object System.out.println(arrayList.get(0)); } }