+ 1
How to get single character input in Java?
I want to get only one character in char variable.
1 Answer
+ 17
Scanner input = new Scanner(System.in);
char c = input.next().charAt(0);
// Taking the input as String and charAt(0) returns the 1st character