版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cqx13763055264/article/details/79480032
先了解一下三种键盘输入的解释:
nextInt(): it only reads the int value, nextInt() places the cursor in the same line after reading the input.
next(): read the input only till the space. It can’t read two words separated by space. Also, next() places the cursor in the same line after reading the input.
nextLine(): reads input including space between the words (that is, it reads till the end of line \n). Once the input is read, nextLine() positions the cursor in the next line.
关于输入类型就不多说了,主要是cursor的区别容易混淆;重点说一下cursor,cursor也就是输入光标。
nextInt()在读取输入后将光标放在同一行中。
next()它不能读两个由空格分隔的单词。另外,在读取输入后将光标放在同一行中 。
nextline()在读取输入之后,将光标放在下一行。
用代码来举一个例子:
暂存。。。。。。。
来源:https://blog.csdn.net/cqx13763055264/article/details/79480032