Programming





Java Operator Precedence

Java Operator Precedence


by Administrator | 25-Mar-2020
Java

Tags:  Java  Operator

Share: 


Operator precedence means if there is more than one operator in an expression then which expression will be solved first and what will be the direction of solving the expression. It is similar to BODMAS rule in mathematics. This is a tabular representation of the precedence and associativity of Java Operators. 

Precedence*

Operator

Type

Associativity

15

()
[]
·

Parentheses
Array subscript
Member selection

Left to Right

14

++
--

Unary post-increment
Unary post-decrement

Right to left

13

++
--
+
-
!
~
type )

Unary pre-increment
Unary pre-decrement
Unary plus
Unary minus
Unary logical negation
Unary bitwise complement
Unary type cast

Right to left

12

*
/
%

Multiplication
Division
Modulus

Left to right

11

+
-

Addition
Subtraction

Left to right

10

<<
>>
>>>

Bitwise left shift
Bitwise right shift with sign extension
Bitwise right shift with zero extension

Left to right

9

<
<=
>
>=
instanceof

Relational less than
Relational less than or equal
Relational greater than
Relational greater than or equal
Type comparison (objects only)

Left to right

8

==
!=

Relational is equal to
Relational is not equal to

Left to right

7

&

Bitwise AND

Left to right

6

^

Bitwise exclusive OR

Left to right

5

|

Bitwise inclusive OR

Left to right

4

&&

Logical AND

Left to right

3

||

Logical OR

Left to right

2

? :

Ternary conditional

Right to left

1

=
+=
-=
*=
/=
%=

Assignment
Addition assignment
Subtraction assignment
Multiplication assignment
Division assignment
Modulus assignment

Right to left

*Larger number means higher precedence.


Comments:


There are no comments.

Enter a new Comment:










Copyright Šprgrmmng. All rights reserved.