Boxing: The basic data type is loaded as a Java class (managed?). Unpacking: Splitting the Java class into a basic data type (unmanaged?). The new version of Java adds the features of the auto-boxing unboxing, which allows the Java base class and basic data types to participate directly in the calculation without conversion. such as: Integer IOBJ = 3//auto-boxing. System.out.println (IOBJ + 12);//automatic unpacking. Automatic boxing unpacking is not supported in earlier versions, and the above two statements are incorrect.
Knowledge point 1:When boxing, the base numeric type is loaded as a Java class integer object, such as: integer i1 = 13, and if the value is within a byte of -128~127, it will be cached first, and the next time a value is loaded as an integer object , it will go to the cached object first to find out if there will be a direct fetch it to use will not produce a new object. This design is to enjoy the meta-mode, if there will be a lot of small objects, and the basic properties of these small objects are the same and will not change when used, there is no need to produce a new object every time, create one on the line.
Experience:This video can be seen in the study of Java in order to improve the efficiency of such considerations, there will be some unique design, is not imagined, so there is no doubt more hands-on experiment, learning from the practice.
Dark Horse programmer _java automatic packing and sharing of basic data video learning notes