How the scanner works
Nextint,nextdouble,next and so on are all token-reading methods. Nextline is not a token-reading method.
How the token Read method works:
Skips any delimiters first, and then reads a token that ends with a delimiter . Then corresponding to the Nextbyte,nextint,nextlong method, the token is automatically converted to a byte,int,long, respectively.
Next,nextline all read a string
Next is the read delimiter split string nextline reads rows separated by row separators.
Row separators are system-defined. The WinDOS platform is \ r \ n, in Unix is \ n, in order to get the row separator under a particular platform
Used: String lineseparator = System.getproperty ("Line.separator");
The token read method cannot read the delimiter after the token. If you call nextline after the token-reading method, read from the delimiter, to the line delimiter. The line delimiter is also read but not part of the string.
Note that following next nextline will cause a few things to happen.
For example
Scanner input = new Scanner (system.in);
Int intvalue= Input.nextint ()
String line = Input.nextline ();
Input 34 123 Return car
Intvalue line is the space plus 123;
If input 34 return to the car 123 return car (actually enter 34 after press ENTER program is finished)
Intvalue or 34,line is an empty string.
How the Java token Read method and scanner work