Jdk prepared using two octal conversion between decimal hexadecimal

Decimal mediated

First, the decimal conversion of other binary

1 . .System OUT .println (Integer.toBinaryString (Integer)); // Decimal Binary turn 

2 .System. OUT .println (Integer.toOctalString (Integer)); // Decimal turn octal 

3 . .System OUT .println ( Integer.toHexString (Integer)); // decimal convert hexadecimal

 

Second, the conversion of other binary to decimal

1.System.out.println(Integer.parseInt(String,2));

2.System.out.println(Integer.parseInt(String,8));

3.System.out.println(Integer.parseInt(String,16));


即 System.out.println(Integer.parseInt(String,index));

or

1.Integer.valueOf(String,2)

2.Integer.valueOf(String,8)
 
3.Integer.valueOf(String,16)


即 Integer.valueOf(String,index)

 

Note: Integer.parseInt (String, index) and Integer.valueOf (String, index) Returns the value of different

Guess you like

Origin www.cnblogs.com/OKDA/p/12481850.html