[Mistakes] next () & nextLine ()

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_30757161/article/details/101036392

difference next () and nextLine () is:

next () method

When reading the content, will effectively filter out invalid characters preceding character, end character for the spacebar encountered before entering a valid character, Tab or Enter key, etc., Next () method will automatically filter out; read only after taking a valid character, next () method until the subsequent space key, Tab key or the Enter key, etc. considered terminator; Next () method of the string can not be obtained with spaces.


nextLine () method
literally a whole line scanning means, it is only the Enter key terminator, i.e. nextLine () method returns all the characters have not been read before the Enter key, it is possible to obtain the spaces of string.
 

Guess you like

Origin blog.csdn.net/qq_30757161/article/details/101036392