Reading some references was possible understand the basics, but not enough to decipher the following code:
public class Expression {
public static void main(String[] args) {
int s = 5;
s += s + mx(s) + ++s + s;
}
static int mx(int s) {
for (int i = 0; i < 3; i++) {
s = s + i;
}
return s;
}
}
Explanation translated
-
First, the left operand (of the assignment) is evaluated to produce a variable: In this case without mystery, because it is
s
; -
There may be an evaluation error on both sides, which interrupts the evaluation: But this is not the case;
Then the right operand is evaluated and produces a value: here the explanation is very summarized, not making clear how the value is produced; >
Questions
- What happens at each expression execution step?
- Are the operands considered individually or is the incremental value for the next operand, for example?