mah*_*hdi -6 java core operators
我执行了代码,输出是19,但我不明白为什么.
public static void main(String[] args)
{
int x = 0;
x = (x = 1) + (x = 2) * (++x) * (x++);
System.out.println(x);
}
Run Code Online (Sandbox Code Playgroud)
您从左到右评估操作数,然后在加法运算符之前计算乘法运算符:
x = (x = 1) + (x = 2) * (++x) * (x++);
1 + (2 * 3 * 3 ) = 19
assignment pre post
operator increment increment
returns the returns the returns the
assigned value incremented value before
value it was incremented
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
121 次 |
| 最近记录: |