Java program to conversion hexadecimal to decimal number

Java program to conversion hexadecimal to decimal number. 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 base8numbering 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. 

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 Numbersdfsdfsdffsdf                                                                                           

Decimal Number is -286331153