How do I parse a String
value in Java to a char
type?
I know how to do it to int and double (for example Integer.parseInt("123")), Is there a class for Strings and Chars?
How do I parse a String
value in Java to a char
type?
I know how to do it to int and double (for example Integer.parseInt("123")), Is there a class for Strings and Chars?
If you want to parse a String to a char, whereas the String object represent more than one character, you just simply use the following expression: char c = (char) Integer.parseInt(s). Where s equals the String you want to parse. Most people forget that char's represent a 16-bit number, and thus can be a part of any numerical expression :)
you can use this trick :