public class BaseToBase {
public static void main(String[] args)
{
System.out.println(Integer.toBinaryString(365));// Convert decimal to binary
System.out.println(Integer.toHexString(365));// Convert decimal to hexadecimal
System.out.println(Integer.toOctalString(365));// Convert decimal to base 8
System.out.println(Integer.toString(10.16));// Decimal conversion to the corresponding base number, not suitable for negative numbers, the first argument is the conversion number, the second argument is the conversion base
System.out.println(Integer.parseInt("1010".2));// Convert N to decimal, return type int, the first argument is a string, the second argument is base
System.out.println(Integer.parseInt("1010".8));
System.out.println(Integer.parseInt("1010".16));
System.out.println(Integer.valueOf("1010".2));// Convert N to decimal, return type int, the first argument is a string, the second argument is base
System.out.println(Integer.parseInt("1010".8));
System.out.println(Integer.parseInt("1010".16)); }}/ / output
101101101
16d
555
10
520
4112
10
520
4112
Copy the code