Parenthesized expressions ( )

Use parentheses to explicitly force the order of expression evaluation. The following expression does not use parentheses to group operands and operators. The parentheses surrounding weight, zipcode are used to form a function call. Note how the compiler groups the operands and operators in the expression according to the rules for operator precedence and associativity:

(-discount * item + handling(weight, zipcode)) < (10 * item))

The following expression is similar to the previous expression, but it contains parentheses that change how the operands and operators are grouped:

(-discount * (item + handling(weight, zipcode))) < (10 * item)

In an expression that contains both associative and commutative operators, you can use parentheses to specify the grouping of operands with operators. The parentheses in the following expression guarantee the order of grouping operands with the operators:

x = f + (g + h);

Related information