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.
there is no fflush() in java to clear the buffer as was in C.
so u can use this piece of code to go to the end of the buffer..
while(sc.hasNext()) {
sc.next();
}
this checks if there is another character in the buffer, and if it is, then it moves on to the next character. It stops when there is no character left in the buffer.
Hope i was able to clear your doubt.. :-)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Stdin and Stdout II
You are viewing a single comment's thread. Return to all comments →
there is no fflush() in java to clear the buffer as was in C. so u can use this piece of code to go to the end of the buffer.. while(sc.hasNext()) { sc.next(); }
this checks if there is another character in the buffer, and if it is, then it moves on to the next character. It stops when there is no character left in the buffer. Hope i was able to clear your doubt.. :-)