Olian04 Olian04 - 4 months ago 9x
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?

int b = s.charAt(0); // 65
char c = (char) b  // 'A'