4. Java Operators

Java operator precedence

  • The Java operator precedence determines the order of the operators that are being evaluated.
  • Operators with a higher precedence are evaluated before the operators with lower a precedence.
  • The following table describes the operator precedence of most common Java operators.
  • Operators on the top will evaluate first.
OrderOperator precedenceAssociativity
1()Left to right
2!Right to left
3*
/
%
Left to right
4+
Left to right
5<
<=
>
>=
Left to right
6==
!=
Left to right
7=Right to left
  • Associativity means, if an expression has more than one operators of the same precedence, they are evaluated according to the associativity.

Consider the following operators and determine which operator will be evaluated first.

Pages: 1 2 3 4 5 6 7