i

JAVA Complete Course

Logical Operators

Logical and “&&” is operators which give us value true if both sides of operands are true. In case, if first operand is false, it will never check the second operand and gives us false. But there is also bitwise and operator “&” which always checks both operands, even if first operand is false.

Logical or “||” is operators which give us value true if at least one operand is true. In case, if first operand is true, it will never check the second operand and gives us true. But there is also bitwise or operator “|” which always checks both operands, even if first operand is true.

Operator

First Operand

Second Operand

Result

&&

true

true

true

&&

true

false

false

&&

false

false

false

||

true

true

true

||

true

false

true

||

false

false

false