AP® Computer Science A glossary
Operator precedence
Course: AP® Computer Science A Shows up in: Unit 1: Using Objects and Methods
The rules that decide how operators are grouped: *, / and % before + and -, same level left to right, parentheses first.
Appears in the course and exam description (CED): 1.3.C.5
At compile time, Java groups values with operators by precedence. Multiplication, division and remainder come before addition and subtraction; operators of the same level go left to right; parentheses change the grouping.
System.out.println(2 + 3 * 4);
System.out.println((2 + 3) * 4);
System.out.println(10 - 4 - 3);
Output:
14
20
3 Learn it properly, with a checkpoint 1.3 Expressions and Output