Title: Key Concept - Operators
Course: CPS 189: Java Certification - Review, Practice & Prepare (Development) > Section: (OLDstyle) Learning Modules

Operators are evaluated according to precedence. The operator of highest precedence is evaluated first; the operator of lowest precedence is evaluated last.

All operators, except the assignment operators, with the same precedence are evaluated from left to right.

Assignment operators with the same precedence are evaluated from right to left.

Parentheses override precedence and modify the evaluation order.

Category | Operators | Precedence
Postfix
expr++ (evaluate and use expr, then increment)

expr-- (evaluate and use expr, then decrement)
Highest

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

Lowest
Unary
++expr (evaluate and increment expr, then use)

--expr(evaluate and decrement expr, then use)

+expr (optional positive value indicator)

-expr (negatice value indicator)

~ (bitwise complement)

! (not)
Multiplicative | * / % (remainder)
Additive | + (Addition or concatenation) -
Shift | << (signed left shift) >> (signed right shift) >>> (unsigned right shift)
Relational
<

>

<=

>=

instanceof (object type comparison)
Equality | == !=
Bitwise AND | &
Bitwise exclusive OR | ^
Bitwise INclusive OR | |
Logical AND | &&
Logical OR | ||
Ternary | ? : (if-then-else statement shorthand)
Assignment
=

Following operators all provide same statement shortcuts. For example:

var += exper is shorthand for var = var + expr

+=

-=

*=

/=

%=

&=

^=

|=

<<=

>>=

>>>=

For more information about operators:

- Click these links to view Oracle's documentations : Operators and Summary of Operators
- Level 1 Study Materials: Unit 1