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.
After a sc.nextInt(); Statement when again for loop runs the first statement is reading a string So is it not possible that it will read an empty string? As we have heard that after reading int we should clear buffer or use empty sc.nextLine(); command.
Please make me clear about why we do not need to clear buffer here?
Thanks! your effort is appreciated.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Output Formatting
You are viewing a single comment's thread. Return to all comments →
After a sc.nextInt(); Statement when again for loop runs the first statement is reading a string So is it not possible that it will read an empty string? As we have heard that after reading int we should clear buffer or use empty sc.nextLine(); command. Please make me clear about why we do not need to clear buffer here? Thanks! your effort is appreciated.