Download Precedence - cs.csustan.edu

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Tensor operator wikipedia , lookup

Canonical normal form wikipedia , lookup

Laws of Form wikipedia , lookup

Boolean algebras canonically defined wikipedia , lookup

?: wikipedia , lookup

Transcript
Operator Precedence
Java operators precedence
How do we evaluate x = 3 + 4 – 6 * 7;
How do we evaluate y = z1 + 20 < 30;
From web
http://www.java-tips.org/java-se-tips/java.lang/what-is-java-operator-precedence.html
Java operator precedence is how Java determines which operator to evaluate first.
In this chart, operator precedence is displayed from highest precedence to lowest
precedence.
Java has lots of operators. I colored the ones we want to know in CS1500 by green.
By the end of CS1500 we may learn some more, but the highlighted are the ones that I need
you to know by the first exam.
Priority Operator
Operation
Order of Evaluation
[]
Array index
()
Method call
.
Member access
++
Prefix or postfix increment
-Prefix or postfix decrement
+Unary plus, minus
~
Bitwise NOT
!
Boolean (logical) NOT
(type)
Type cast
new
Object creation
3
*/%
Multiplication, division, remainder
Left to Right
+Addition, subtraction
+
String concatenation
<<
Signed bit left shift
>>
Signed bit right shift
>>>
< <=
> >=
instanceof
==
!=
Unsigned bit right shift
Less than, less than or equal to
Greater than, greater than or equal to
Reference test
Equal to
Not equal to
Copyright: R. Silverman
1
8
11
12
13
&
&
^
^
|
|
&&
||
?:
=
*= /= += -= %=
<<= >>= >>>=
&= ^= |=
Bitwise AND
Boolean (logical) AND
Bitwise XOR
Boolean (logical) XOR
Bitwise OR
Boolean (logical) OR
Boolean (logical) short-circuit AND
Boolean (logical) short-circuit OR
Conditional
Assignment
Left to Right
Left to Right
Left to Right
Right to Left
Combined assignment
(operation and assignment)
Notes:
 Expressions inside parentheses are evaluated first
 Nested parentheses are evaluated from the innermost parentheses to the outermost
parenthesis.
Copyright: R. Silverman
2