Chandler-Gilbert Community College Spring 2005
Java Operator Precedence

Home
Schedule
Instructor
Links
Syllabus

Java Operator Precedence

Java evaluates expressions according to the rules of operator precedence. Java evaluates operators listed at the top of the table first.  If operators are on the same row,  Java evaluates them from left-to-right.

++, --, +, -, ~, !, explicit cast

*, /, %

+, -

<<, >>, >>>

<, <=, >, >=, instanceof

==, !=

&

^

|

&&

||

?:

= and all compound assignments

The java operators are:

Operator Purpose
+ addition of numbers, concatenation of Strings
+= add and assign numbers, concatenate and assign Strings
- subtraction
-= subtract and assign
* multiplication
*= multiply and assign
/ division
/= divide and assign
| bitwise OR
|= bitwise OR and assign
^ bitwise XOR
^= bitwise XOR and assign
& bitwise AND
&= bitwise AND and assign
% take remainder
%= take remainder and assign
> greater than
>= greater than or equal to
< less than
<= less than or equal to
! boolean NOT
!= not equal to
++ increment by one
-- decrement by one
>> shift bits right with sign extension
>>= shift bits right with sign extension and assign
<< shift bits left
<<= shift bits left and assign
>>> unsigned bit shift right
>>>= unsigned bit shift right and assign
&& boolean AND
|| boolean OR
== boolean equals
= assignment
~ bitwise NOT
?: conditional
 

Home ] Up ] Instructor ] Links ] Syllabus ]

date last modified: 01/14/03
copyright 2005 Greg Swan