0

Scanner

How do I take a user input of a character.Please help

15th Jul 2017, 5:12 AM
Ayushya Shah
Ayushya Shah - avatar
2 ответов
+ 1
import java.util.*; public class character { public static void main(String[] args) { Scanner in = new Scanner(System.in); char alpha = in.next().charAt(0); //Don't use next line... } }
15th Jul 2017, 8:13 AM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar
0
You can do the following: Scanner in = new Scanner(System.in); char yourChar = in.nextLine().charAt(0);
15th Jul 2017, 5:44 AM
Deddy Tandean