How to convert/parse from String to char in java?
You can use the .charAt(int) function with Strings to retrieve the char value at any index. If you want to convert the String to a char array, try calling .toCharArray() on the String.
String g = "line";
char c = g.charAt(0); // returns 'l'
char[] c_arr = g.toCharArray(); // returns a length 4 char array ['l','i','n','e']
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);