Notation for logic in Java
问题 Absolutely basic Java question which I'm having a hard time finding on Google. What does the following mean: (7 & 8) == 0? Is that equivalent to writing: 7 == 0 || 8 == 0? I wrote a quick main which tests this, and it seems to be the case. I just wanted to make sure I'm not missing anything. 回答1: Nope. & is bitwise and. It sets a bit if the corresponding bits are set in both inputs. Since in binary, 7 is 111 and 8 is 1000 , they have no bits in common, so the result is 0 . There isn't really