Operator Precedence : Operators « Operators « Java Tutorial






Operators with a higher precedence are executed before those of a lower precedence.

Operators on the same line have the same precedence:

Operator Precedence GroupAssociativityOperator Precedence
(), [], postfix ++, postfix --leftHighest
unary +, unary -, prefix ++, prefix --, ~, !right
(type), newleft
*, /, %left
+, -left
<<, >>, >>>left
< ,<= , >, >=, instanceof
==, !=
&left
^left
|left
&&left
||left
?:left
=, +=, -=, *=, /=, %=, <<=, >>=, >>>=, &=, |=, ^=rightlowest


3.1.Operators
3.1.1.Six categories of operators
3.1.2.Operator Precedence
3.1.3.The op= Operators
3.1.4.The ternary operator (The Conditional Operator): result = value>conditionValue ? result1 : result2
3.1.5.Tests all the operators on all the primitive data types to show which ones are accepted by the Java compiler