# Convert decimal to binary in java

In this post, we will see how to convert decimal to binary in java.

There are lot of ways to convert decimal to binary in java.Let’s explore them one by one.

Table of Contents

💻 Awesome Tech Resources:
• Looking for ⚒️ tech jobs? Go to our job portal.
• Looking for tech events? Go to tech events 🗓️ Calendar.️

## Using Integer.toBinaryString() method

You can simply use inbuilt Integer.toBinaryString() method to convert a decimal

Output:

Binary representation of 12 : 1100
Binary representation of 32 : 100000
Binary representation of 95 : 1011111

## Using iterative array approach

Output:

Enter a decimal number
12
Binary representation is : 1100

## Using stack

Output:

Enter decimal number:
32
Binary representation is : 100000

That’s all convert decimal to binary in java.

import_contacts

### You may also like: ## Related Posts

• 30 December

### Rock Paper Scissors Game in Java

Learn about how to implement Rock Paper Scissors game in java.

• 25 December

### Find automorphic number in java

Learn about how to find automorphic number in java using different methods

• 25 December

### Find nth prime number in java

Learn about how to find nth prime number in java.

• 06 October

### Implement distance formula in java

In this post, we will see how to implement distance formula between two points in java. Formula to find distance between two points ( x1, y1) and (x2 , y2) is d= sqrt( (x2-x1)^2+ (y2 – y1)^2) Here is simple program to calculate distance between two points in java. 💻 Awesome Tech Resources: Looking for […]

• 05 October

### Print prime numbers from 1 to 100 in java

In this program, we will print prime numbers from 1 to 100 in java. A prime number is a number which has only two divisors 1 and itself. To check if the number is prime or not, we need to see if it has any other factors other than 1 or itself. If it has, […]

• 31 March

### FizzBuzz program in java

In this post, we will see how to program FizzBuzz in java. Fizzbuzz is a fun game played generally by school children. It is simple game in which when your turn comes, you need to say the next number. So here are rules of the game: If number is divisible by 3, then you need […]

## Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.