In this section, you will learn how to convert a binary number into a decimal number.
Convert Binary to Decimal
In this section, you will learn how to convert a binary number into a decimal number. The java.lang package provides the facility to convert the integer data into the binary to decimal.
Code Description:
In this program, you will learn the use of parseLong() method. Define a class "BinaryToDecimal" using the parseLong() method. This method is used to parse the string argument as a signed decimal long. This method has been used for converting a long to a string and a String to a long.
Here is the code of this program:
import java.lang.*;
|
Output of this program:
C:\corejava>java BinaryToDecimal Enter the Binary value: 10010 Decimal:=18 C:\corejava>_ |