In addition to the comparison operators that produce boolean results (usually comparing numeric values), there are three boolean operators that take boolean values as operands and produce boolean results.
Operator Meaning &&AND: both operands must be truefor the whole expression to betrue||OR: one or the other operand must be truefor the whole expression to betrue(vertical bars are usually above the\symbol on the keyboard)!NOT (negation): if the operand is truethen the expression isfalse; if the operand isfalsethen the expression istrue.Examples:
if ( ( 0 < i ) && ( i < k ) ) { ... } if ( fish.atWall() || ( randNum < 2 ) ) { ... } if ( ( hour > 6 ) && ( ! todayIsSunday ) ) { ... }