String to char (keyboard entry problem)

Taking three pieces of information from the keyboard

first is of String : No Problem here
secons is of Int : No problem here.

Third is of char: The problem

Using the BufferedReader.readline or BufferedReader.read() methods  
I keep getting a 'Cannot convert String to Char error' on compilation.

What method should i use to read this character ?
 I see lots of examples of charAt().. But this is not the case. I am assuming that the user will enter either M or F
Exceptions can be dealt with later.

So how is the first character 'char' read in from the keyboard.
pbehanAsked:
Who is Participating?
 
maheshexpConnect With a Mentor Commented:
char c = (char)System.in.read();
0
 
krakatoaCommented:
String.toCharArray();
0
 
objectsCommented:
> So how is the first character 'char' read in from the keyboard.

the user still needs to enter carriage return, so you still need to do a readLine().

char c = in.readLine().charAt(0);
0
 
gnoonCommented:
char ch = (char) buffreader.read(); // you can

but

char ch = (char) buffreader.readLine(); // you cann't
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.