Need help understanding Scanner.nextLine()

I have the following code and it works just fine:

see next post

Sorry for splitting the post. New users are only allowed to paste one item at a time in posts :frowning:

However, if I reverse the order of my input requests for “fullName” and “age”, after entering age in the terminal and hitting enter, the code skips the input request for “fullName” and finishes. See below, code and terminal I/O:

Any help in understanding this would be greatly appreciated!

btw, I did try the latter code using .next(). However, as expected, it only grabbed the first token.

Hi, looks like you’re missing an input.nextLine(); after age. I’m also new to this btw, but as I understand it, you need to add it so that it clears out the new line from the scanner. If you do that, it should run just fine. Hope this helps.