1.

Convert hexadecimal number to decimal number in Java

Answer»

The parseInt() METHOD converts hexadecimal to decimal. It can even convert octal to decimal. You just NEED to set the radix. For hexadecimal, the radix is 16.

The following is an EXAMPLE:

public class Demo {   public static void main( String args[] )   {       // hexadecimal string       String STR = "298";       // hex to decimal       System.out.println("Decimal = "+Integer.parseInt(str, 16));   } }

The output:

Decimal = 664


Discussion

No Comment Found