toBinaryString() Method in java, using predefined method

Java Programming Language / Number Class in java

956

Program:

 
class DecimalBinaryExample{

    public static void main(String a[]){
    	
    	System.out.println("Binary representation of 125: ");
    	System.out.println(Integer.toBinaryString(125));
        System.out.println("\nBinary representation of 55: ");
        System.out.println(Integer.toBinaryString(55));
        System.out.println("\nBinary representation of 999: ");
        System.out.println(Integer.toBinaryString(999));
    }
}

Output:

Binary representation of 125:
1111101

Binary representation of 55:
110111

Binary representation of 999:
1111100111
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.