QuesAns Print Page – CSKC
Sign In

Search

siteicon
Q&A ICSE2017-03J #7251

Question:

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

Answer:

next() read a single token i.e. all characters from the current position till a whitespace or tab or new line is encountered.
nextLine() reads an entire line i.e. all characters from the current position till a new line is encountered.