Java Program To Convert Hexadecimal To Decimal

Sharing is healthy !!

Learn java program to convert hexadecimal to decimal.

Basically to convert a hexadecimal number to decimal number using manual calculation is quite hard. So in the java program below we areĀ leveraging two methods namely get_Value() and to_Convert() to do the conversion. The java program accepts value from the end user to do the conversion from hexadecimal to decimal. Let’s get into example,

Example: Java Program To Convert Hexadecimal To Decimal

```import java.util.Scanner;

public class Hexa_To_Decimal {

int number;

void get_Value(){
System.out.println("Java Program To Convert Hexadecimal To Decimal");
Scanner sc = new Scanner(System.in);
System.out.println("Please enter number to convert: ");
number = Integer.parseInt(sc.nextLine(),16);
}

void to_Convert(){
String decimal = Integer.toString(number);
System.out.println("The Decimal value is: " + decimal);
}

public static void main(String[] args) {

Hexa_To_Decimal htd = new Hexa_To_Decimal();
htd.get_Value();
htd.to_Convert();

}
}```

Output:

Sharing is healthy !!