What is the result of the Java expression 2 + 3 * 4?

The story behind the answer

The result of the Java expression 2 + 3 * 4 is 14. Java evaluates multiplication before addition because the multiplication operator has higher precedence than the additive operators. The expression is therefore grouped as 2 + (3 * 4), producing 2 + 12, or 14.

This rule is part of Java’s C-style operator precedence system. Parentheses can override it: (2 + 3) * 4 evaluates to 20. Multiplication, division, and remainder share a precedence level, as do addition and subtraction; operators at the same level are generally evaluated from left to right.

A common mix-up is to calculate strictly from left to right and obtain 20. That is not how Java parses this expression. The compiler effectively builds an expression structure in which the multiplication is nested inside the addition. The same principle applies to variables, such as 2 + quantity * price.

Java’s arithmetic operators work with numeric types, and because all four literals here are integer literals, the calculation uses integer arithmetic. No decimal conversion or rounding is involved.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: