Home » Java Convert Hex to Decimal

Java Convert Hex to Decimal

by Online Tutorials Library

Java Convert Hexadecimal to Decimal

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

Java Hexadecimal 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 hexadecimal to decimal in java.

Test it Now

Output:

10 

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

Test it Now

Output:

10 15 289 

Java Hexadecimal to Decimal conversion: Custom Logic

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

Test it Now

Output:

Decimal of a is: 10 Decimal of f is: 15 Decimal of 121 is: 289 

You may also like