Advertisements
Advertisements
Question
The Scanner class method used to accept words with spаce:
Options
next()nextLine()Next()nextString()
MCQ
Advertisements
Solution
nextLine()
Explanation:
The nextLine() method reads the entire input string, including spaces, until it hits the end of the line (when Enter is pressed). In contrast, the standard next() method stops reading at the very first space it encounters.
shaalaa.com
Is there an error in this question or solution?
Chapter 5: Library Classes - Exercises [Page 134]
