+ 4
Which methods are used to take a character from keyboard in java
I am using char Y=sc.nextLine(); or char Y=sc.next(); but it is error https://code.sololearn.com/cSioi3651m88/?ref=app
4 Answers
+ 9
Use the following line:
char Y = sc.next().charAt(0);
It'll save the first character of the string as the char variable.
+ 2
lot of thanks Shamima
+ 1
did you included the Scanner class??
0
yes