If you strip off the 0x
prefix for your hex String
representation, you can use Integer.parseInt
and cast to char
.
See edit below for an alternative (possibly more elegant solution).
String s = "0x7D";
// | casting to char
// | | parsing integer ...
// | | | on stripped off String ...
// | | | | with hex radix
System.out.println((char)Integer.parseInt(s.substring(2), 16));
Output
}
Edit
As njzk2 points out:
System.out.println((char)(int)Integer.decode(s));
... will work as well.