+ 2

Char in Scanner Java

How to scan single char in java? coz thr is no method like char nextChar() and String have multiple characters.

9th Mar 2017, 10:02 AM
AshishFF
AshishFF - avatar
2 ответов
+ 1
Scanner scan = new Scanner(System.in); System.out.println("What's your name?"); scan.hasNext(); ... is that what you mean?
9th Mar 2017, 10:14 AM
Nicholas Yambar
+ 1
I found this on stackoverflow:- char c = scanner.next().charAt(0); its working.
9th Mar 2017, 10:32 AM
AshishFF
AshishFF - avatar