Java Autoboxing and Unboxing
Java 1.5 introduced a special feature of auto conversion of primitive types to the corresponding Wrapper class and vice versa. Autoboxing : 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. Unboxing : It is just the reverse process of autoboxing. Automatically converting an object of a wrapper class to its corresponding primitive type is known as unboxing. For example – conversion of Integer to int, Long to long, Double to double etc. Primitive type Wrapper class boolean Boolean byte Byte char Character float Float int Integer long Long short Short double Double When does the autoboxing and unboxing happens in Java Autoboxing Lets see few cases with examples, where autoboxing happens. Case 1 : Wh