Java.util.Scanner.nextInt() Method - Tutorialspoint[
^]
You don't have to change the variable. If you need to input two distinct values, just call
nextInt()
method twice. It is also advised to check for the validity of the input, and react accordingly if it wasn't of expected format. As a general rule,
never trust user-input strings.
Scanner keyboard = new Scanner(System.in);
int option1, option2;
if (keyboard.hasNextInt())
{ option1 = keyboard.nextInt(); }
else
{ }
if (keyboard.hasNextInt())
{ option2 = keyboard.nextInt(); }
else
{ }