15. Precedence Rules « Contents »   

Precedence determines which of the different operators +, /, etc. used in an expresssion, are carried out first. When evaluating expressions java applies the usual algebraic precedence rules.

  1. Calculate terms inside brackets
  2. Multiplication, Division and Modulus
  3. Addition and Subtraction

In the event of equal precedence, work from left to right.

Expression with precedence order Evaluates to 38

Adding brackets changes the order of evaluation. When brackets are nested the inner one is evaluated first.

   « Back Back to Top Next »