YOu can't convert a string into a char because this isn't rational. A string is often MANY chars. Which one do you want to become your char? The first? The last?
What you can do is convert a string into an array of chars or get a char at a specific location that you specify. For instance, if you are reading user input and want to find out if the user entered a 'y' or a 'n' you can do:
String input = reader.readLine();
if (input!= null && input.charAt(0) == 'y')
// user entered a 'y'
else
// user entered something else
Alternately you can get the chars that make up this string:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.