Re: hasNextInt() question
When you declare the Scanner variable, it automatically begins to read for user input. It will pause at userInput.hasNextInt until it reads input.
So basically, user input is stored separately from the variables you declare. When you use .hasNextInt, it returns true or false, and when you use .nextInt, it returns the integer value itself.
Re: hasNextInt() question
Take a look at this for more information on using the Scanner class.
Scanner (Java 2 Platform SE 5.0)
Also wrap your code in this format to preserve formatting.
[C0DE=java]
<code>
[/C0DE]
Re: hasNextInt() question
the scanner class as it is used here is for taking input from the standard input which is the keyboard. the hasNext() method of class Scanner is a method that returns true until the end of file indicator is pressed. the end of file indicator for windows is ctrl z while that of linux is ctrl d. so the application/program will continue to take input until you press the end of file indicator