0

How can we scan a character?

I don't know how to scan only one character using char

15th Feb 2018, 4:00 PM
Sathya
Sathya - avatar
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.
15th Feb 2018, 4:36 PM
Ankit Saxena
Ankit Saxena - avatar
15th Feb 2018, 4:37 PM
Harjeet Singh
Harjeet Singh - avatar