This behavior is not the result of operator precedence, but the rules in Java, Python, and C # that determine the order in which expressions are evaluated. In particular, in Java, Python, and C #, expressions are evaluated from left to right. This is not the case, for example, in C and C ++, where the result of what you wrote would be undefined.
You may be familiar with this C puzzle:
int i = 1;
printf("%d, %d\n", i++, ++i); // what is printed?
C . 1, 3
, 2, 2
- . Java # Python 1, 3
( , Python pre- postfix ++).
- . , .
, op1
op2
. , :
e1 op1 e2 op2 e3
,
((e1 op1 e2) op2 e3)
(e1 op1 (e2 op2 e3))
, e1
, e2
e3
.