sanddbox wrote:That was probably added by mistake - using next is fine since "yes" or "no" is only one word.
No, I think it is better to use nextLine in place of next. I believe his error was that by using next he read the line without advancing to the next line, then when the loop was ran next there was nothing left in the line to assign to sentence. sentence then became null, thus a length of 0, thus an IndexOutOfBounds error. I could be wrong though, it's been a few years since I used Java.
Edit: s/a/an
Editx2: I should have mentioned that redeclaring/making a local variable the Scanner object worked because then it's new, so it starts with the next line of input, kind of artificially moving past the end of the reply line, even though next was called on the reply line. Not sure if that made sense, I had trouble coming up with a better wording than "making it new makes it new"






