We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
for all the people who are saying that how will the scanner.hasNext() condition will come false,then listen folks.
it is not described here but the input is coming from a text file and the scanner object starts to read from the top and reads upto the end. when the end of the text file comes as there is nothing to read the condition become false and loop brakes.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java End-of-file
You are viewing a single comment's thread. Return to all comments →
for all the people who are saying that how will the scanner.hasNext() condition will come false,then listen folks. it is not described here but the input is coming from a text file and the scanner object starts to read from the top and reads upto the end. when the end of the text file comes as there is nothing to read the condition become false and loop brakes.