A.1. Operator Precedence

Operators are shown in decreasing order of precedence from top to bottom (Fig. A.1).

Figure A.1. Operator precedence chart.

Operator

Description

Associativity

++

unary postfix increment

right to left

--

unary postfix decrement

 

++

unary prefix increment

right to left

--

unary prefix decrement

 

+

unary plus

 

-

unary minus

 

!

unary logical negation

 

~

unary bitwise complement

 

( type )

unary cast

 

*

multiplication

left to right

/

division

 

%

remainder

 

+

addition or string concatenation

left to right

-

subtraction

 

<<

left shift

left to right

>>

signed right shift

 

>>>

unsigned right shift

 

<

less than

left to right

<=

less than or equal to

 

>

greater than

 

>=

greater than or equal to

 

instanceof

type comparison

 

==

is equal to

left to right

!=

is not equal to

 

&

bitwise AND

left to right

 

boolean logical AND

 

^

bitwise exclusive OR

left to right

 

boolean logical exclusive OR

 

|

bitwise inclusive OR

left to right

 

boolean logical inclusive OR

 

&&

conditional AND

left to right

||

conditional OR

left to right

?:

conditional

right to left

=

assignment

right to left

+=

addition assignment

 

-=

subtraction assignment

 

*=

multiplication assignment

 

/=

division assignment

 

%=

remainder assignment

 

&=

bitwise AND assignment

 

^=

bitwise exclusive OR assignment

 

|=

bitwise inclusive OR assignment

 

<<=

bitwise left shift assignment

 

>>=

bitwise signed-right-shift assignment

 

>>>=

bitwise unsigned-right-shift assignment

 

Категории