This is very simple, just cast your char
to int
too see Character code:
System.out.println('A'); // A
System.out.println((int) 'A'); // 65
In Java character are encoded with UTF-16
The char data type (and therefore the value that a Character object encapsulates) are based on the original Unicode specification, which defined characters as fixed-width 16-bit entities. The Unicode standard has since been changed to allow for characters whose representation requires more than 16 bits. The range of legal code points is now U+0000 to U+10FFFF, known as Unicode scalar value.
Sample code to print character codes from specified string
char[] chars = "abcdefghijklmnopqrstuvwxyz01234567890....".toCharArray();
System.out.println("char unicode hex code");
for (char c : chars)
System.out.println(String.format(
"'%s' : \\u%04x : 0x%04X : %s", c, (int) c, (int) c, (int) c));
}
Result
char unicode hex code
'a' : \u0061 : 0x0061 : 97
'b' : \u0062 : 0x0062 : 98
'c' : \u0063 : 0x0063 : 99
'd' : \u0064 : 0x0064 : 100
'e' : \u0065 : 0x0065 : 101
'f' : \u0066 : 0x0066 : 102
'g' : \u0067 : 0x0067 : 103
'h' : \u0068 : 0x0068 : 104
'i' : \u0069 : 0x0069 : 105
...