First, the methods commonly used on Integer
Package com.bjpowernode.java_learning; public class D77_1_ { public static void main (String [] args) { Integer I1 = new new Integer (10 ); // the type Integer type int int I2 = i1.intValue (); System.out.println (I2); // important: static int parseInt (string s) into a digital string int Age = the Integer.parseInt ( "25" ); System.out.println (Age); // int. price Integer.parseInt = ( "ABE"); // this statement will be successful programming, but are having problems running, parameters can only accept digital // important: static double parseDouble (String s) Double D1 = Double.parseDouble ( ". 3" ); System.out.println (D1); // Static method: static String toBinaryString (int i) is converted into an integer i (string) binary returns // static String toHexString (int i) convert to hex // static String toOctalString (int i) to octal System.out.println (Integer.toHexString ( 90 )); System.out.println (Integer.toBinaryString ( 89 )); System.out.println (Integer.toOctalString ( 89 )); // convert one type or int type Integer String type: both methods, direct initialization; use Integer.valueOf () method System.out.println (Integer. valueOf ( "45" )); System.out.println (Integer.valueOf ( 45)); System.out.println("=================================="); } }
2.Integer \ int \ String three types of conversion
//int->Integer Integer i5 = Integer.valueOf(10); //Integer->int int i6 = i5.intValue(); //String ->Integer Integer i7 = Integer.valueOf("10"); //Integer ->String String s5 = i5.toString(); //String -> int int i8 = Integer.parseInt("10"); //int -> String String s6 = 10 + "";
Second, automatic packing, automatic unpacking
1.JDK5.0 new features
The following properties are suitable after JDK1.5 version, including 1.5,
Package com.bjpowernode.java_learning; public class D77_2_EncasementAutomatically { public static void main (String [] args) { // before JDK5.0 // INT-> packing Integer Integer I1 = new new Integer (10 ); // Integer -> int unpacking int I2 = i1.intValue (); // after JDK5.0, comprising 5.0 Integer I3 = 10; // autoboxing int I4 = I3; // automatically unpacking System.out.println (i3 ); System.out.println (I4); M1 ( 445);// autoboxing System.out.println (M2 ( 85,50)); // first automatic packing, unpacking and then automatically } public static void M1 (Object O) { System.out.println (O); } public static int M2 (I1 Integer, Integer I2) { return I1- I2; } }
2. In-depth auto-boxing and auto-unboxing
(1) Automatic boxing and unboxing is a conceptual automatic program compilation phase, independent and operating procedures;
(2) Automatic boxing and unboxing automatic main purpose is to facilitate programming.
Third, the source code:
D77_1_IntegerAndIntAndStringTransform.java
D77_2_EncasementAutomatically.java
https://github.com/ruigege66/Java/blob/masterD77_1_IntegerAndIntAndStringTransform.java
https://github.com/ruigege66/Java/blob/master/D77_2_EncasementAutomatically.java
2.CSDN:https://blog.csdn.net/weixin_44630050
3. Park blog: https: //www.cnblogs.com/ruigege0000/
4. Welcomes the focus on micro-channel public number: Fourier transform public personal number, only for learning exchanges, backstage reply "gifts" to get big data learning materials