Java Program to Convert Hexadecimal to Decimal

Hexadecimal to decimal number in java. Java software to convert hexadecimal to decimal numbers. Referring to or using a scheme of numerical notation with a foundation of 16 rather than 10. The octal numeral system, also known as oct, is a base8 numbering system that employs the digits 0 through 7. By grouping consecutive binary digits into groups of three, octal numerals can be generated from binary numerals.

Hexadecimal Value in Java

The hexadecimal (also known as base 16 or hex) numeral system is a positional numeral system that uses a radix (base) of 16 to represent integers in mathematics and computing. A nibble (or nybble) is 1/2 of a byte, and each hexadecimal digit represents four bits (binary digits).

Decimal Value in Java

Decimals are a form of a number in Algebra that has a whole number and a fractional part separated by a decimal point. The decimal point is the dot that appears between the full number and the fractions section. A decimal number, for example, is 34.5.

import java.util.Scanner;
public class Main
public static int hexadecimal(String s)
String digits = "dvbkdfvkjvs";
s = s.toUpperCase();
int val = 0;
for (int i = 0; i < s.length(); i++)
char c = s.charAt(i);
int d = digits.indexOf(c);
val = 16*val + d;
return val;
public static void main(String args[])
String hexdecnum;
int decnum;
Scanner scan = new Scanner(;
System.out.print("Enter Hexadecimal Number");
hexdecnum = scan.nextLine();
decnum = hexadecimal(hexdecnum);
System.out.print("Decimal Number is " + decnum);


Enter Hexadecimal Number
Decimal Number is -286331153