I have seen the .NET foundation may not be unfamiliar with this packing and unpacking concept. First, we must clarify that in Java, there are two distinct data types: value types and reference types. The data of the value type is not an object, so the memory and resources occupied are relatively small, but it cannot be called to call it to Tostring (), havehcode (), getclass (), equals (), etc., can not be added directly In the collection; the data of the reference type is an object, which takes up more memory and resources, but provides a rich access method, as a real object, can be placed directly into the collection. The so-called packing is to package the value type with the reference type of the reference type, so that they can have the identity of the object. If we can pack the INT type into an object of the Integer class, or package the double to double, and so on. The so-called unpacking is in contrast to the direction of the box, re-simplifies the object of the reference type of Integer and Double to the value type data. Before J2SE 5.0 is released, we can only handle the boxes and unpacks, and now, the compiler can help us complete these necessary steps. The following code I offer two versions of the box and unboxes, one version uses manual way, another version handed these obvious code to the compiler to complete: public static void manboxingunboxing (int i) {arraylist
Public static void autoboxingunboxing (INT i) {arraylist