This tutorial contains example source codes written in java dealing on how to convert hexadecimal to decimal. As we all know hex to decimal conversion using manual computation is extremely hard. As well know hexadecimal numbers is of base 16 while decimal is of base 10 which is equivalent to our counting numbers. For reference you might want to take a look on the  Mathematical procedures on how to do hexadecimal to decimal conversion in order for you understand what we are trying to accomplish.

Java Hexadecimal to Decimal Conversion

We would be leveraging the use of static method of parseInt(String input, radix) of Integer class. This method accepts the radix parameter which is of course we are expecting it to be 16 as mentioned above. Basically we have implemented a mechanism to accepts input from the console and then we print the converted value. Moreover we will be validating as well the console input, throwing a ‘Invalid Input’ once the conversion fails. This validation is in place for us to handle the possible exception that can be thrown during parsing.

Sample Output: Java hex to decimal conversion