You are viewing a single comment's thread. Return to all comments →
I'm 20 days late, but the reason is: hasNext() checks if there is a string remaining in the Scanner; and returns false only when nothing is left there, which is equivalent to EOF
But the input is being given line by line. How can you say it will search for EOF? It keeps on asking for input!!!
I had also the same question, I could not find any easy explenation over net.
You can use a while loop to look for it
If there is no next line it will terminate the loop