📜  java代码示例中sc.nextLine()和sc.next()有什么区别

📅  最后修改于: 2022-03-11 14:52:15.553000             🧑  作者: Mango

代码示例1
Their differences are...

next() can 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.