What is the difference between the Scanner class functions next() and nextLine()?

Views 5

Answer:

next() nextLine()
It reads the input only till space so it can read only a single word. It reads the input till the end of line so it can read a full sentence including spaces.
It places the cursor in the same line after reading the input. It places the cursor in the next line after reading the input.

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.