Study results in success in a course.
It is useful to have some rules for rewriting boolean expressions. Here is an easy one:
!!A
is equivalent toA
The operand A stands for a true/false value or an expression that results in a true/false value. This truth table shows the rule:
A | !A | !!A |
---|---|---|
true | false | true |
false | true | false |
Rewrite the following if
statement:
if ( !(value != 399) ) System.out.println("Correct Value"); else System.out.println("Wrong Value");