public class Main {
    public static void main(String[] args) {
        int tmp = 32; // 100000
        int tmp2 = 1; // 000001
        String fometTmp = String.format("%6s",Integer.toBinaryString(tmp));
        //fometTmp = fometTmp.replaceAll("1", "#");
        //fometTmp = fometTmp.replaceAll("0", " ");
        System.out.println(fometTmp);

        String fometTmp2 = String.format("%6s",Integer.toBinaryString(tmp2));
        //fometTmp2 = fometTmp2.replaceAll("1", "#");
        fometTmp2 = fometTmp2.replaceAll(" ", "0");
        System.out.println(fometTmp2);


    }
}

<결과 창>

100000
000001

+ Recent posts