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.
A great explanation is contained in the book Absolute Java page 83 " Pitfall: Dealing with the line terminator,'\n'.
Im sure by now you must understand why nextLine() is used twice, in order to get rid of the empty string after invoking nextInt(), but this comment is for anyone else who reads your comment and is also interested in finding a refrence to read about this problem more.
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 →
A great explanation is contained in the book Absolute Java page 83 " Pitfall: Dealing with the line terminator,'\n'.
Im sure by now you must understand why nextLine() is used twice, in order to get rid of the empty string after invoking nextInt(), but this comment is for anyone else who reads your comment and is also interested in finding a refrence to read about this problem more.