x++
is evaluated first. It's post-increment, so 10
is the value of the expression, then x
is incremented to 11
.
++x
is evaluated next. It's pre-increment, so x
is incremented to 12
and 12
is the value of the expression.
The rest is simple multiplication, and 10 * 12 = 120.
This behavior is not dependent on which JVM is used; all JVMs must behave this way, as specified by the Java Language Specification.
The JLS, Section 15.14.2 covers post-increment expressions:
The value of the postfix increment expression is the value of the variable before the new value is stored.
The JLS, Section 15.15.1 covers pre-increment expressions:
The value of the prefix increment expression is the value of the variable after the new value is stored.