80
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.
Output:
10
Let’s see another example of Integer.parseInt() method.
Output:
10 21 31
Java Binary to Decimal conversion: Custom Logic
We can convert binary to decimal in java using custom logic.
Output:
Decimal of 1010 is: 10 Decimal of 10101 is: 21 Decimal of 11111 is: 31
Next TopicJava Decimal to Binary