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.
.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.
Java Stdin and Stdout II
You are viewing a single comment's thread. Return to all 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!