
216 CHAPTER 5 Flow of Control,Part 1: Selection
TABLE 5.7 Truth Table for DeMorgan’s Laws
a b !a !b a && b a || b !(a && b) !a || !b !(a || b) !a && !b
true true false false true true false false false false
true false false true false true true true false false
false true true false false true true true false false
false false true true false false true true true true
TABLE 5.8 The Logical NOT Operator Applied to Relational and Equality Operators
Expression ! ( Expression )
a == b a != b
a != b a == b
a < b a >= b
a >= b a < b
a > b a <= b
a <= b a > b
In Java, therefore, using the first law, we see that
!( a && b ) is equivalent to !a || !b
Using the second ...