0
How can we scan a character?
I don't know how to scan only one character using char
2 Answers
0
First of all import Scanner class
Then create Scanner Object
Then call next method and chatAt method
Eg
import java.util.Scanner;
//Now in any method
char x;
Scanner b = new Scanner(System.in);
x=b.next().charAt(0);
Here next() will return String and charAt(0) will return first character of that string.