BFOIT - Introduction to Computer Programming

Java Operator Precedence

Operations always come before others. The following table lists the specific precedences of Java operators. The larger the precedence number the sooner it is evaluated.

As an example, in the expression ( cents + 100 * dollars ) multiplication will be executed first in an expression since its precedence number is 12, larger than addition's 11.

Operator Description Precedence Number
++, -- post-increment, post-decrement
16
++, -- pre-increment, pre-decrement
15
~ bitwise complement
14
! logical complement
14
+, - numerical signs
14
( typename ) type conversions, casting
13
*, /, % multiplication, division,
remainder
12
+, - addition, subtraction
11
<<, >>, >>> bit shifts
10
<, <=, >, >= relational
9
==, != equality
8
& bitwise AND
7
^ bitwise EXCLUSIVE OR
6
| bitwise INCLUSIVE OR
5
&& conditional-and
4
|| conditional-or
3
?, : if, else expression
2
=, +=, -=, *=, /= assignment
1