Next: Boolean expressions with variables:
Up: Unit 04
Previous: Operations that involve values
Java is equipped with the primitive data type boolean that allows us
to deal with expressions that denote truth values (i.e., expressions whose
value can be either true or false).
We recall first the basic notions of boolean algebra.
Domain |
truth values true and false |
Operators |
and |
conjunction: a and b is true
both a and b are true |
|
or |
disjunction: a or b is true
a is true or b is true (or both are) |
|
not |
negation: not a is true
a is false |
Example:
- true and false is false
- true or false is true
- not true is false
- false or (true and (not false)) is equivalent
to
false or (true and true), which is equivalent to
false or true, which is equivalent to
true
Next: Boolean expressions with variables:
Up: Unit 04
Previous: Operations that involve values