본문 바로가기

Java & Html

[Java] 10진수 <> 2진수, 8진수, 16진수 변환

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

import java.lang.Integer;

class  EveryDayTest30 {
    public static void main(String[] args) {
        int param = 47;

        // 10 -> 2
        System.out.println("10진수 -> 2진수 : " + Integer.toBinaryString(param));
        // 10 -> 8
        System.out.println("10진수 -> 8진수 : " + Integer.toOctalString(param));
        // 10 -> 16
        System.out.println("10진수 -> 16진수 : " + Integer.toHexString(param));
        // 2 -> 10
        System.out.println("2진수 -> 10진수 :"+ Integer.parseInt(Integer.toBinaryString(param), 2));
        // 8 -> 10
        System.out.println("8진수 -> 10진수 :"+ Integer.parseInt(Integer.toOctalString(param), 8));
        // 16 -> 10
        System.out.println("16진수 -> 10진수 :"+ Integer.parseInt(Integer.toHexString(param), 16));

    }
}

'Java & Html' 카테고리의 다른 글

Eclipse에 FindBugs 설치  (0) 2016.11.01
Java Google Style Guide  (0) 2016.10.12
코드를 메모리에 올려 사용하자  (0) 2016.01.27
Spring Transaction  (0) 2015.12.27
JSP 커스텀 태그(Custom Tag)  (0) 2015.07.07