I currently am using try scannerIn.nextInt() = x
, where x
was initialized as an int
from the start. So if the user enters anything besides an integer, it catches the exception and asks again, which is dandy.
My issue is that, if the user enters something like eleven eleven eleven
, or 11 11 11
, the spaces messes it all up since each separate input is counted separately instead of all at once.
scannerIn.nextLine()
would only work for a string correct? How do I read a whole line at once so it throws the exception that they did not enter a single answer, regardless of type?