In this section, you will learn to change hexadecimal number into decimal. The java.lang package provides the functionality to convert a hexadecimal number into decimal.
Code Description:
This program takes a hexadecimal number at console and converts it into a decimal number using parseInt() method. This method parses the string value as a signed integer in the radix specified by the second argument. Here the second argument is 16 to convert a hexadecimal into a decimal number.
parseInt():
This method takes two arguments: hexadecimal and 16. It converts a hexadecimal
number into a decimal number.
Here is the code of this program:
import java.io.*;
|
Output of this program.
| C:\corejava>java HexadecimalToDecimal Enter the Hexadecimal number: 32 Decimal:=50 C:\corejava> |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Convert Hexadecimal to Decimal View All Comments
Post your Comment