• + 0 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();