#Scanner Not working
23 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @scarlet grove! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
If Scanner#nextLine reads an empty line after calling a different Scanner#next method, take a look at this StackOverflow post.
I am so confused what do u mean?
Did you read the StackOverflow post?
Yeh, still dont get it
you called nextInt()
And then you call nextLine()
nextLine tries to read the remainder of the line with the nextInt call
which is an empty line
So how does one fix that?
Add an additional scanner.nextLine(); before System.out.println("Adjective: ");
this consumes the remaining line
I know what to do now but I am having a difficult time understand how it works
ok when you call nextInt, the scanner reads an int
but it's still stuck at the same line
so when calling nextLine, it finishes the line where it read the int
and returns the remainder of that line (which is empty)
only when calling nextLine a second time, you are reading the actual line
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
