boolean
is another primitive typetrue
and
false
Operator Example Meaning ==
i == k
equals? (same values?) !=
i != 0
not equal to? <
i < 0
less than? <=
i <= k
less than or equal to? >
i > 0
greater than? >=
i >= k
greater than or equal to?
boolean
values. For example,
the method call fish.atWall()
will return true
if the fish is at the wall (and facing the wall), and will return
false
otherwise. (See the AquaFish class documentation.)
boolean
variables. For example,
int i = 2; int k = 3; boolean same = i == k; // same will be false boolean iIsSmaller = i < k; // iIsSmaller will be true boolean isAtWall = fish.atWall(); // isAtWall will be true if the // fish is at the wall
boolean
expressions are frequently used in conditional
statements (next topic).