How do I parse a String
value to a char
type, in Java?
I know how to do it to int and double (for example Integer.parseInt("123")
).
Is there a class for Strings and Chars?
If your string contains exactly one character the simplest way to convert it to a character is probably to call the charAt
method:
char c = s.charAt(0);