PackageCom.mydemo.controller;ImportJava.util.Scanner; Public classHelloWorld { Public Static voidMain (string[] args) {System.err.println ("HelloWorld"); System.out.println ("HelloWorld"); System.out.println (system.in); System.out.println (System.out); System.out.println (System.err); Scanner Scanner=NewScanner (system.in); String nextline=Scanner.nextline (); }}
Operation Result:
HelloWorld Helloworld[email protected][email Protected][email protected]
How to block the scanner:
1 PackageCom.mydemo.controller;2 3 ImportJava.util.Scanner;4 5 Public classHelloWorld {6 Public Static voidMain (string[] args) {7@SuppressWarnings ("Resource")8Scanner Scanner =NewScanner (system.in);//This line breaks the point9String nextline =Scanner.nextline (); This line breaks.Ten System.out.println (nextline); This line breaks. One } A}
Debug Run:
Until the 9th line, press F6 will not go down, the console input will go down.
So the nextline () of the scanner object is a blocking method.
Java standard output stream, standard error output stream, standard input stream, and scanner