. 1 Package cn.learn; 2 . 3 Import of java.util.ArrayList; . 4 . 5 / * . 6 packaging java.lang, the basic operation of high efficiency type 7 Packing: the basic data types of packaging Packaging 8 1. Construction Method 9 integer i = new integer (may be int, may be an integer value string) 10 unpacking: type substantially removed in the wrapper class . 11 12 is the basic type of string type conversion 13 basic types -> string, returns a string 14 1. basic type value + "" (the empty string) 15 2. static method toString wrapper class is overloaded toString Object, not a thing 16 3.String class string valueOf static (I int) . 17 string -> basic type, returns a base data type 18 1. parseXXX wrapper class ( "numeric string type") . 19 EG: Integer categories: static int parseInt ( "value") 20 is 21 is * / 22 is public class wrapperClass { 23 is public static void main (String [] args) { 24 25 // Constructor - Obsolete 26 is Integer NUM = new new Integer ( . 1); // . 1 27 Integer = num01 new new Integer ( ". 1"); // . 1 28 29 // unpacking 30 int num02 num.intValue = (); // . 1 31 is 32 // autoboxing 33 Num03. 5 = Integer ; 34 is // Integer num04 = ". 5"; given 35 the ArrayList <Integer> = List new new the ArrayList <> (); 36 // autoboxing actually list.add (new Integer (1)) 37 [ List.add (. 1 ); 38 is 39 // automatically unpacking, in fact, is num03.valueOf () + 2; 40 int num04 num03 = +2; // . 7 41 is System.out.println (num04); 42 is // the ArrayList automatic unpacking 43 is int I = List.get (0); // . 1 44 is 45 // basic types -> string 46 STR = 66+ String ""; // "66" 66 47 String Str0 = Integer.toString (500); // returns a character string "500" 500 48 String str1 = String.valueOf (55); // "55" 55 49 System.out.println (STR + + Str0 str1); // 6650055 50 51 is // string -> basic types 52 is int P1 = the Integer.parseInt ( "55"); // needs to be int, 53 is System.out.println (P1 + 2); // 57 is 54 is int P2 = ( int ) 'A' ; 55 System.out.println (P2);//97 56 57 58 59 } 60 61 }