Scanner input = new Scanner(System.in);
String str = input.nextInt();
while ( (str.nextInt() != 5) || (str.nextInt() != 10) ){
str = input.nextInt()
}
The code should invoke the nextInt()
method every time the user types a number other than 5 or 10. What is happening here is that when I type 5 or 10 it keeps repeating, invoking the method nextInt()
.