Zebra0.com

java booleanBoolean Expressions

Boolean Expressions

A Boolean expression can be evaluated as true or false

The variables x, y, and z have the values shown below:

x=0;
y=5; 
z=8;

Each expression below is TRUE:

ExpressionExplanation
x < y0 is less than 5
z > y8 is greater than 5
y < z5 is less than 8
y <= z5 is less than or equal to 8
x != z0 is not equal to 8
z >= y8 is greater than or equal to 5

Continuing with the same values for x, y, and z, each expression below is FALSE:

ExpressionExplanation
x > y0 is NOT greater than 5
z < y8 is NOT less than 5
y == z5 is NOT equal to 8
y <= z5 is less than or equal to 8
y != y8 is not equal to 8 is false
x != x0 is not equal to 0 is also false

NEXT: Drill on Boolean expressions