Java Stdin and Stdout II

  • + 2 comments

    .nextDouble or .nextInt doesn't consider nextline character. So if you don't call scanner.nextLine right before String string = scanner.nextLine when you press enter after giving Integer/Double as input. the "enter or say nextline character" is stored in variable string and not the actual "string input" which you give after pressing enter key.

    http://stackoverflow.com/questions/12265216/why-cant-i-enter-a-string-in-scannersystem-in-when-calling-nextline-method

    http://stackoverflow.com/questions/13102045/skipping-nextline-after-using-next-nextint-or-other-nextfoo-methods

    I referred these links for the same question. Hope it helps!