Next: Comparison operators
Up: Unit 04
Previous: The primitive data type
The following are simple expressions of type boolean:
- The constants true, false;
- Variables declared of type boolean;
- Comparison operators applied to primitive data types: == ,
!= , > , < , >= , <=
- Calls to predicates (i.e., methods that return a value of type
boolean).
Complex expressions can be constructed from simple boolean expressions using
the boolean operators !, &&, and ||. For such
operators, the following precedences hold:
- !
- &&
- ||
Example: The following is a correct expression of type boolean:
a || ! b && c
It is equivalent to:
a || ((! b) && c)
Next: Comparison operators
Up: Unit 04
Previous: The primitive data type