Logical Operators


Java logical operators combine two or more conditions and return boolean true or false accordingly.

1. && (Logical AND)

System.out.print(5 == 10 && 10 == 10);

// prints false

2. || (Logical OR)

System.out.print(5 == 10 || 10 == 10);

// prints true

3. ! (Logical Not)

System.out.print(!false);

// prints true