Latest :

Java Program To Convert Decimal To Binary | Vice Versa

Java program to convert decimal to binary. Here is the following code that you are searching for it. The following program has been written in three different ways using arrays, using the static method, using recursion, and vice versa conversion from Binary to decimal.

  • What is binary and how it represents?

A binary number is a number expressed in the base 2 numeral system. A Binary Number is made up of only 0s and 1s.

Example of a binary number is :

101010

  • What is Decimal?

A decimal number system is a term with base 10. It’s most commonly used number system.  The decimal number system consists of 10 digits from 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

1. Java Code Using Arrays 

Here is the program using arrays with sample outputs.

Output:

2. Using static Method

  • There you go another program using the static method to convert decimal to binary.
Output:

3. Using Recursion 

Another sample program using recursion method.

Output:

 

4. Using Stack

Output:
x

Check Also

Java Pyramid Star Pattern Program | Patterns

Java program to print Pyramid star pattern program. We have written the below print/draw Pyramid ...