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 158 views
3 answers 331 views
2 answers 269 views
269 views asked Jan 12, 2022 by avibootz
1 answer 171 views
2 answers 183 views
...