Java Reference
In-Depth Information
The main unary operators are , ! , ++ , —— , [] , and new . You will notice that ++ and —— appear
in each of the top two rows in Table C.1. Those in the top row take a single operand on their
left, while those in the second row take a single operand on their right.
Table C.1
Java operators,
highest precedence
at the top
[]
.
++
——
( parameters )
++
——
+
!
~
new
( cast )
*
/
%
+
<<
>>
>>>
<
>
>=
<=
instanceof
==
!=
&
^
|
&&
||
?:
=
+=
— =
*=
/= %= >>= <<= >>>= &= |= ^=
C.2
Boolean expressions
In boolean expressions, operators are used to combine operands to produce a value of either
true or false . Such expressions are usually found in the test expressions of if statements and
loops.
The relational operators usually combine a pair of arithmetic operands, although the tests for
equality and inequality are also used with object references. Java's relational operators are:
== equal to
not equal to
!=
less than
<= less than or equal to
<
greater than
>= greater than or equal to
>
The binary logical operators combine two boolean expressions to produce another boolean
value. The operators are:
&& and
|| or
^ exclusive or
Search WWH ::




Custom Search