Computer Science, asked by anushka3635, 8 months ago

difference between next() and nextLine() of scanner class in java​

Answers

Answered by akathwal004
2

next() : The function of next () is that the cursor remains in the same line .

nextLine() : The function of nextLine() is that the cursor moves to the next line.

Answered by sneha413639
1

Answer:

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).

Similar questions