Java进制转换

2014-05-28· 4596 次浏览
## 代码 ```java public static void main(String[] args) { int number = 10; System.out.println("转为二进制:"); System.out.println(Integer.toString(number, 2)); System.out.println(Integer.toBinaryString(number)); System.out.println("\n转为八进制:"); System.out.println(Integer.toString(number, 8)); System.out.println(Integer.toOctalString(number)); System.out.println("\n转为十六进制:"); System.out.println(Integer.toString(number, 16)); System.out.println(Integer.toHexString(number)); System.out.println("\n八进制声明(012):"); System.out.println(012); System.out.println("\n十六进制声明(0xa):"); System.out.println(0xa); } ```