- 2
Decimal to binary conversion in java??đ
3 Answers
+ 4
Java Convert Decimal to Binary
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.
public class DecimalToBinaryExample1{ Â
public static void main(String args[]){ Â
System.out.println(Integer.toBinaryString(10));Â Â
System.out.println(Integer.toBinaryString(21));Â Â
System.out.println(Integer.toBinaryString(31));Â Â
}}Â Â
For more see this https://www.javatpoint.com/java-decimal-to-binary
+ 2
Thank you allđ
+ 1
Integer.toBinaryString(int yourdecimal)
Returns in string