티스토리 뷰
int num = 92;
//10 -> 2, 8, 16
String binNum = Integer.toBinaryString(num);
String octNum = Integer.toOctalString(num);
String hexNum = Integer.toHexString(num);
System.out.println(binNum); //1011100
System.out.println(octNum); //134
System.out.println(hexNum); //5c
//2, 8, 16 -> 10
int binToDec = Integer.parseInt(binNum, 2);
int octToDec = Integer.parseInt(octNum, 8);
int hexToDec = Integer.parseInt(hexNum, 16);
System.out.println(binToDec); //92
System.out.println(octToDec); //92
System.out.println(hexToDec); //92
참고
'Language > Java' 카테고리의 다른 글
JVM의 Garbage Collector (0) | 2021.04.09 |
---|---|
Java Virtual Machine 구조 (0) | 2021.04.09 |
데이터 타입별 형변환 방법 (0) | 2021.02.22 |
copyOf() / copyOfRange() (0) | 2021.02.18 |
for-each / Iterator (0) | 2021.02.18 |
댓글