Boolean Expressions
A Boolean expression is a Java expression that, when evaluated, returns a Boolean value: true or false. Boolean expressions are used in conditional statements, such as if, while, and switch.
The most common Boolean expressions compare the value of a variable with the value of some other variable, a constant, or perhaps a simple arithmetic expression. This comparison uses one of the following relational operators:
|
Operator |
Description |
|
|
Returns |
|
|
Returns |
|
|
Returns |
|
|
Returns |
|
|
Returns |
|
|
Returns |
A basic Boolean expression has this form:
expression relational-operator expression
Java evaluates a Boolean expression ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access