Decimal to Binary Number Converter in Java Program

Number Conversion: Converting decimal to Binary number format using Java Coding

If you want to convert the decimal number to binary number just use the below program. The conversion is done by using the method Integer.toBinaryString. In this program I just get the input from the user using BufferedReader and input stream.
Source code program

import java.lang.*;
public class Decimal2Binary{
public static void main(String args[]) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(;
System.out.println("Enter the decimal value:");
String decimal = bf.readLine();
int i = Integer.parseInt(decimal);
String by = Integer.toBinaryString(i);
System.out.println("Binary: " + by);

The Output of the above program will be

D:Java est>java Decimal2Binary
Enter the decimal value:
Binary: 1100101

D:Java est>

You can also try the online Decimal to Binary, Hexa, Octal Converter to check the output of this program.

Related Topic Java Program for Decimal to Hex converter
Binary Subtraction in Java
Decimal to Binary Number Converter in C Program
Convert Decimal to Hex in PHP
Binary to Decimal Conversion
Java 2011   Privacy Policy  Terms of Service  Feedback