public class MyClass {
public static void main(String args[]) {
String hex = "C";
char ch = hex.charAt(0);
if (ch <= 'F' && ch >= 'A') {
int value = ch - 'A' + 10;
System.out.println("Decimal value = " + value);
}
else if (Character.isDigit(ch)) {
System.out.println("Decimal value = " + ch);
}
else {
System.out.println("Hex digit error");
}
}
}
/*
run:
Decimal value = 12
*/