Java Reference
In-Depth Information
Table A.2.4 Boolean operators. x and y are Boolean types. x and y can be
expressions that result in a Boolean value. Result is a Boolean true or
false value.
Operator
Name
Description
Conditional
AND
If both x and y are true, result is true.
If either x or y are false, the result is false
If x is false, y is not evaluated.
x&&y
Boolean
AND
If both x and y are true, the result is true.
If either x or y are false, the result is false
Both x and y are evaluated before the test.
x&y
x || y
Conditional
OR
If either x or y are true, the result is true.
If x is true, y is not evaluated.
x | y
Boolean
OR
If either x or y are true, the result is true.
Both x and y are evaluated before the test.
Boolean
NOT
If x is true, the result is false.
If x is false, the result is true.
!x
Boolean
XOR
If x is true and y is false, the result is true.
If x is false and y is true, the result is true.
Otherwise, the result is false.
Both x and y are evaluated before the test.
x ^ y
Table A.2.5 Comparison operators. x and y are numeric or char types only
except for “== and ! = operators, which can also compare references. If
mixed types, then the narrower type converted to wider type. Returned value is
Boolean true or false .
Operator
Description
Is x less than y?
x < y
Is x less than or equal to y?
x <= y
Is x greater than y?
x > y
Is x greater than or equal to y?
x >= y
Is x equal to y?
x == y
Is x not equal to y?
x!= y
Search WWH ::




Custom Search