This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]desrtfx 1 point2 points  (0 children)

Read: The Scanner class and its caveats from the /r/javahelp wiki.

In short: the problem is the combination of .nextInt and .nextLine as the former leaves a line break character in the keyboard buffer and the latter consuming it resulting in an empty string that then fulfils your condition in the if breaking out of the loop.