| Operator | Operation |
|---|---|
| & | Logical AND |
| ^ | Logical XOR |
| && | Short-circuit AND |
| ! | Logical Unary NOT |
| &= | AND assignment |
| = | |
| ^= | XOR assignment |
| == | Equal to |
| ! = | Not Equal to |
| ?: | Ternary if-then-else |
Boolean logical operators shown above operate only on boolean operands.
Short-circuit logical operators will not evaluate the right hand operand if the outcome of the expression can be determined from the left operand alone.
A && B; results in false when A is false no matter what B is and A || B results in true when A is true no matter what B is.
String x = null;
if(x!=null && x.length()>1){}; // doesnot compute right operand
if(x!=null & x.length()>1){}; // computes both operand and throws error