Olian04 Olian04 - 1 year ago 86
Java Question

Char to int and back again

I want to find an integer representation of a character, then later on find a character representation of an int.

My current solution is this, but it doesn't work:

String s = "A"
Integer b = Character.getNumericValue(s.toCharArray()[0]); // 10
char c = Character.toChars(b)[0]; // (blank)

How should i do this?

Answer Source
int b = s.charAt(0); // 65
char c = (char) b  // 'A'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download