There are two types of variables in Java, one is an object, and its ancestors are java.Lang.Object; the other is numeric type, such as int, short, char, etc. Because Boolean, int, short, char is numeric types, etc. Autoboxing & Unboxing in Java 5.0 is designed to simplify this process.
Previously: Integer i = new integer (0); int bar = I.intValue (); Java 5.0: Integer i = 0; int BAR = i; i ; // can even be like this
Is it more convenient than before, but the principle is not changed before, just JRE5.0 automatically conversion.
You must use Object using Collection, so in the following example: list list = new arraylist (); list.add (new integer (10));
5.0 After the new autobox, you can modify: list list = new arraylist (); list.add (10);
It can then be optimized to: list list = new arraylist (); list.add (10);