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 ...
Get Java For Dummies Quick Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.