Skip Top Navigation Bar

Applying DeMorgan's Law

DeMorgan's Law

DeMorgan's Law applies in situations when a not (!) operator is being used in combination with either the and (&&) or the or (||) operators.

Truth Table to Prove DeMorgan's Law

Rule Description Example
!(value1 && value2) evaluates to !value1 || !value2 where value1 and value2 are boolean expressions. !((5 > 7) && (3 !=0)) is equivalent to (5 <= 7) || (3 == 0)
!(value1 || value2) evaluates to !value1 && !value2 where value1 and value2 are boolean expressions. !((val + 5 <= 0) || (5 == 5)) is equivalent to (val + 5 > 0) && (5 != 5)

Resources

Practice: Using Logic Operators

Next Learn Tutorial

Learn: Comparing Objects with the Equals Method