Java Program to convert hexadecimal number to decimal number


Use the parseInt() method with the second parameter as 16 since it is the radix value. The parseInt() method has the following two forms.

static int parseInt(String s)
static int parseInt(String s, int radix)

To convert hex string to decimal, use the 2nd syntax and add radix as 16, since hexadecimal radix is 16.

Integer.parseInt("12", 16)

Example

 Live Demo

public class Demo {
   public static void main( String args[] ) {
      // converting to decimal
      System.out.println(Integer.parseInt("444", 16));
   }
}

Output

1092

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 26-Jun-2020

243 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements