Logical Operators

noun

say it: “LOJ-ih-kul OP-uh-ray-terz” /ˈlɑdʒɪkəl ˈɑpəreɪtərz/

The symbols && (and), || (or) and ! (not) that combine or flip true-or-false conditions.

What is Logical Operators in Java?

Logical Operators — Operators that combine or reverse boolean conditions.

class Venue {
    boolean canEnter(int age) {
        boolean isAdult = age >= 18;
        boolean isSenior = age >= 65;

        if (isAdult && !isSenior) {
            return true;
        }

        return false;
    }
}

In a sentence

  • “With logical operators I checked that the username was filled in && the password was at least 8 characters.”

Level: Novice · More Java terms at this level

Updated

In other subjects