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

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.