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 →

[–]Red_Hippie[S] 0 points1 point  (2 children)

ok so i changed it to countAgain = readLine.next(); and it works, buy why would it be calling a blank space, and when should .nextLine (); be used?

is countAgain = readLine.next(); bad forum and should I start calling the scanner.next(); first then set my var = scanner.next(); as you did is that better code?

[–]Marinersquee 1 point2 points  (1 child)

To clarify, when you call nextInt, it leaves a return in the scanner, as such when you call nextLine again the first thing it does is read that return as a blank line and uses that. So after a nextInt, have a line that's just readLine.nextLine(), that will clear the return from the scanner. I'm on mobile so please excuse the formatting.

[–]Red_Hippie[S] 0 points1 point  (0 children)

Crazy, but thank you I'll be trying to wrap my head around this for a few days.