Scanner input = new Scanner(System.in);
selection = input.nextInt();
while (selection != 1 || selection != 2 || selection != 3 || selection != 4){
System.out.println("*");
selection = input.nextInt();
}
The above code just goes into a loop no matter what I enter it just repeats itself. I’m probably making a silly mistake somewhere but I can’t see it probably due to lack of sleep. Any help is welcome, thanks.
All the or signs have been changed to && signs but it still keeps looping?
replace
by
selection != 1 || selection != 2
is alwaystruebecauseselection` cannot be not 1 and be not 2.