Java int type convert decimal to binary String

Description

Java int type convert decimal to binary String


public class Main {
    public static void main(String args[]) {
        int num = 0b1010; //binary
        System.out.printf("\n In Decimal = %d ", num);
        System.out.printf("\n In Octal = %o ", num);
        System.out.printf("\n In Hexa Decimal = %x ", num);
        System.out.printf("\n In Binary = %s ", Integer.toBinaryString(num));
    }//from   ww w . j  a v a 2s .com

}



PreviousNext

Related