stackquestions stackquestions - 10 months ago 62
Java Question

Java boolean statement with OR operator trouble

int optionselect = 3;
System.out.println(optionselect != 1 || optionselect != 2 || optionselect != 3);

This statement is printing true for me no matter what I set the int optionselect to. I'm not sure how or why.

Answer Source

It's always going to not equal at least 2 of those, because it can only equal 1 of them at a time.