Convert Decimal Number to Binary String using Java

Integer.toBinaryString method

package app;

public class Main
{
    public static void main(String[] args)
    {
        int decimalNumber = 20;
        String binaryString = Integer.toBinaryString(decimalNumber);

        System.out.println(binaryString);
    }
}

Leave a Comment

Cancel reply

Your email address will not be published.