For some reason a sentinel value will not work as expected
public static int play() {
String input;int result;
do {
input = JOptionPane.showInputDialog("Do you want to play-Enter 1 if yes , 0 if no");
result = Integer.parseInt(input);
} while (result != 1 || result != 0);
return result;
}
This code above never works but it works just fine if i change the condition from while (result != 1 || result != 0);
to while (result < 0 || result > 1);
Why is that so and how can i make not equal work in a do...while
loop in java ?
Thanks