Home » Java Convert Binary to Decimal

Java Convert Binary to Decimal

by Online Tutorials Library

Java Convert Binary to Decimal

We can convert binary to decimal in java using Integer.parseInt() method or custom logic.

Java Binary to Decimal conversion: Integer.parseInt()

The Integer.parseInt() method converts string to int with given redix. The signature of parseInt() method is given below:

Let’s see the simple example of converting binary to decimal in java.

Test it Now

Output:

10 

Let’s see another example of Integer.parseInt() method.

Test it Now

Output:

10 21 31 

Java Binary to Decimal conversion: Custom Logic

We can convert binary to decimal in java using custom logic.

Test it Now

Output:

Decimal of 1010 is: 10 Decimal of 10101 is: 21 Decimal of 11111 is: 31 

You may also like