Take a char input from the Scanner

前端 未结 22 2284
[愿得一人]
[愿得一人] 2020-11-22 05:16

I am trying to find a way to take a char input from the keyboard.

I tried using:

Scanner reader = new Scanner(System.in);
char c = reade         


        
22条回答
  •  攒了一身酷
    2020-11-22 06:14

    import java.io.*;
    
    class abc // enter class name (here abc is class name)
    {
        public static void main(String arg[])
        throws IOException // can also use Exception
        {
            BufferedReader z =
                new BufferedReader(new InputStreamReader(System.in));
    
            char ch = (char) z.read();
        } // PSVM
    } // class
    

提交回复
热议问题