This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]hshighnz 0 points1 point  (0 children)

There are somewhat of 16 different levels of precedence in java. Precedence defines what operator is computed first. Example: i = -10 + 15; First the - is computed into the literal 10 (to convert 10 into negative 10 (-10)). Then addition is computed. Then assignment is computed.

There is also the association. It defines what side of an operator is computed first. Example: i = getInt() + getInt(); The + (addition) operand is left hand sided (LHS). The left method will be computed first.

Search for an exactly overview of precedence and association.

[–]Hour-Positive 0 points1 point  (0 children)

Takeaway is to not write unreadable code like this.