3.8. Operator Precedence

There are rules regarding the order of precedence the compiler will follow when executing a mathematical statement with multiple operators. These are generally the standard mathematical rules for operator precedence:

  1. Operators inside parentheses

  2. Multiplication and division (left to right)

  3. Addition and subtraction (left to right)

This short program simply sets two different variables to the value of a mathematical expression result. The expression uses multiple mathematical operators. Each expression uses identical operators and numeric values. One expression shows left to right precedence, while the other shows parenthetical enforcement of precedence.

 /* File: chp3.opPrecedence.java Purpose: demo operator precedence Author: ...

Get Java™ for ColdFusion® Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.