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 174 views
3 answers 357 views
2 answers 303 views
303 views asked Jan 12, 2022 by avibootz
1 answer 184 views
2 answers 216 views
...