Hello,
Hopefully I am asking this in the correct place. This is in relation to question 8 of Chapter 4 in the Sierra/Bates
SCJP book.
there is an if statement that reads;
Boolean b2 = false;
"if((b2 = false) | (21%5) > 2) s += "x";
The question answers say that s never gets the "x" appended. I'm having trouble understanding how this actually works.
b2 is false so that renders TRUE on the left side of the "|". But but the
test of 21%5 >2 renders FALSE.
So the way I read this since it is not a || being used here is that one is true so the test should be true. The logical operator is | and not an &.
What am I failing to understand about the Non Short-Circuit operator. I'm not able to figure out what is really happening here.
Thanks for any help you can provide.