进制转换
2019-03-29 本文已影响0人
白纸糊
public class App {
public static void main( String[] args ) {
int i = 192;
System.out.println("---------------------------------");
System.out.println("十进制转二进制:" + Integer.toBinaryString(i));
System.out.println("十进制转八进制:" + Integer.toOctalString(i));
System.out.println("十进制转十六进制:" + Integer.toHexString(i));
System.out.println("---------------------------------");
System.out.println("二进制转十进制:" + Integer.valueOf("11000000", 2).toString());
System.out.println("八进制转十进制:" + Integer.valueOf("300", 8).toString());
System.out.println("十六进制转十进制:" + Integer.valueOf("c0", 16).toString());
System.out.println("---------------------------------");
}
}