next up previous
Next: Precedence between operators of Up: Unit 04 Previous: Comparing floating point numbers

Predicates

Methods that return a value of type boolean are called predicates.

Example: The following is the definition of a static method that is a predicate:

public static boolean implies(boolean a, boolean b) {
    return (!a || b); // not a or b
}
It can be used as shown in the following code fragment:
boolean x, y, z;
...
z = implies(x, y);


next up previous
Next: Precedence between operators of Up: Unit 04 Previous: Comparing floating point numbers