✏️ Explanatory Question

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

👁 80 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

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.