We can convert decimal to binary in java using Integer.toBinaryString() method or custom logic.
Java Decimal to Binary conversion: Integer.toBinaryString()
The Integer.toBinaryString() method converts decimal to binary string. The signature of toBinaryString() method is given below:
public static String toBinaryString(int decimal)
Let's see the simple example of converting decimal to binary in java.
Output:
Java Decimal to Binary conversion: Custom Logic
We can convert decimal to binary in java using custom logic.
Output: