How can I read input from the console using the Scanner class in Java?

前端 未结 15 1977
我寻月下人不归
我寻月下人不归 2020-11-21 06:19

How could I read input from the console using the Scanner class? Something like this:

System.out.println(\"Enter your username: \");
Scanner = i         


        
15条回答
  •  南笙
    南笙 (楼主)
    2020-11-21 06:55

    You can flow this code:

    Scanner obj= new Scanner(System.in);
    String s = obj.nextLine();
    

提交回复
热议问题