Hi Cameron,
I'm not sure whether the discussion was to be here or in the Q&A
thread, but I don't want to look at the Q&A first and see the answer (even though I know it ;-)
The thing to remember is that, in any expression involving a post-fix operation, the value of the variable x
before the "++" operation is used in evaluating the expression
each time it appears. Further, the entire expression on the right will be evaluated before the "+=" operator is applied.
Since evaluation proceeds left-to-right:
x += x++ * x++ * x++;
by substitution, this is equivalent to:
x += (x) * (x+1) * (x+2)
or:
x += (x^2 + x) * (x+2)
or:
x += (x^3 + 2x^2 + x^2 + 2x)
or:
x += (x^3 + 3x^2 + 2x)
or:
x = x^3 + 3x^2 + 3x
so if x=2:
x = 2^3 + 3 (2^2) + 3(2)
or:
x = 8 + 12 + 6
x = 26
If you think that's a toughie, try figuring out the cost of upgrading from the original "Java Platform 2" certification to the array of certifications available now that cover the same technical territory, and whether there is any "upgrade" discount!
JeffInTampa