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.
nextLine read leftovers also so after gving input of double we press enter nextLine reads it and returns empty so we need to add 1 more nextLine so that it can read the line we typed after pressing enter ( our input string ).
so we write it like:
scan.nextLine(); // to clear buffer
String str = scan.nextLine();
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 1: Data Types
You are viewing a single comment's thread. Return to all comments →
nextLine read leftovers also so after gving input of double we press enter nextLine reads it and returns empty so we need to add 1 more nextLine so that it can read the line we typed after pressing enter ( our input string ).
so we write it like: scan.nextLine(); // to clear buffer String str = scan.nextLine();