+ 1

How to get single character input in Java?

I want to get only one character in char variable.

28th Mar 2017, 3:05 PM
Muhammad Abdullah
Muhammad Abdullah - avatar
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
28th Mar 2017, 3:10 PM
Shamima Yasmin
Shamima Yasmin - avatar