Difference between boolean & operator and && operator
Answer :
& evaluates both sides of the operation
&& evaluates the left side of the operation and if it’s true then it continues and evaluates the right side
Please see Boolean Logical Operators table below for reference:
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 |