How to convert decimal number to binary in Java

2 Answers

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        System.out.println(Integer.toBinaryString(10));
    }

}


/*
run:

1010

*/

 



answered Jul 23, 2016 by avibootz
0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        System.out.println(Integer.toBinaryString(30));
    }

}


/*
run:

11110

*/

 



answered Jul 23, 2016 by avibootz

Related questions

1 answer 289 views
3 answers 532 views
2 answers 452 views
452 views asked Jan 12, 2022 by avibootz
1 answer 289 views
2 answers 349 views
...