What are Java Boolean Logical Operators?

The Boolean logical operators operate on boolean operands.

Logical Operator List

 

The following table lists all Java boolean logical operators.

Operator  Result

&              Logical AND

|               Logical OR

^                 Logical XOR (exclusive OR)

||               Short-circuit OR

&&              Short-circuit AND

!                 Logical unary NOT

&=             AND assignment

|=               OR assignment

^=            XOR assignment

==            Equal to

!=             Not equal to

? :            Ternary if-then-else

True table

 

The following table shows the effect of each logical operation:

   A         B      A | B   A & B    A ^ B  !A

False False False False  False True

True  False True  False  True   False

False True  True  False  True    True

True  True  True  True    False    False