Java operator precedence guidelines

As far as the “Real World” is concerned, it’s probably fair to say:

  • enough programmers know that multiplication/division take precedence over addition/subtraction, as is mathematically the convention
  • hardly any programmers can remember any of the other rules of precedence

So, apart from the specific case of */ vs +-, I’d really just use brackets to explicitly define the precedence intended.

Leave a Comment