Java Logical Operators
Logical operators
&&, ||, &, | and !
&
And. Returns a true value if both expressions are true. This operator always evaluates both expressions.
&&
And. Returns a true value if both expressions are true. This operator only evaluates the second expression if necessary.
expression
Is a construct made up of variables, operators, and method invocations, which are constructed according to the syntax of the language, that evaluates to a single value.
1.5 - 1.7
Java Development Kit (JDK)
!
Not. Reverses the value of the expression.
|
Or. Returns a true value if either expression is true. This operator always evaluates both expressions.
||
Or. Returns a true value if either expression is true. This operator only evaluates the second expression if necessary.
1.2 - 1.4
Software Development Kit (SDK)
short-circuit operator
The && and || only evaluate the second expression if necessary.
Web apps
applet
order of precendence for logical, arithmetic and relational operations
arithmetic, then relational and then logical