Autoboxing

Autoboxing and unboxing is introduced in Java 1.5 to automatically convert primitive type into boxed primitive( Object or Wrapper class). autoboxing allows you to use primitive and object type interchangeably in Java on many places like assignment, method invocation etc.

ArrayList<Integer> intList = new ArrayList<Integer>();
intList.add(1); //autoboxing – primitive to object
intList.add(2); //autoboxing

Leave a comment