Precedence problems are easier to reason about once you split them into two separate ideas. **Precedence** decides which operator grabs an operand first, so it only matters when two different operators compete. **Associativity** decides the grouping when two operators of *equal* precedence compete, and it applies only within a single level.
precedence which operator binds tighter 2 + 3 * 4 -> 2 +(3 * 4), because * is higher associativity which of two equal operators goes first 100 / 10 / 5 ->(100 / 10) / 5, because / is left-associativeThe practical consequence is that precedence questions are about the table below, while associativity questions only ever arise inside a single row of it.
int a = 10 + 5 * 2;
// precedence: * first, so 20
int b =(10 + 5) * 2;
// parentheses: 30
int c = 100 / 10 / 5;
// associativity: left to right, so 2