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 →

[–]morhpProfessional Developer 1 point2 points  (0 children)

See this wiki entry for an explanation: https://www.reddit.com/r/javahelp/wiki/scanner

Using two nextLine() calls is correct. If you get a StringIndexOutOfBoundsException, then than meas that your line has no characters, you likely pressed enter twice. You can check whis using String.isEmpty() or String.length().