java - 单目运算符问题;
PHPz
PHPz 2017-04-18 10:17:44
0
2
588

int a=4;
b=a*a++;
b的结果?

单目运算符优先级比双目运算符高,理应是先累加然后相乘得到20,为什么程序运算结果是16?

PHPz
PHPz

学习是最好的投资!

reply all(2)
Ty80
int a = 4;
int b = a*++a; // 20

The priority of increment and decrement is indeed higher than *. For example, in the above example, is operated first ++a

But there is still a difference between ++a a++

洪涛

a++ takes the value first and then calculates the increment by 1, ++a takes the value first and then takes the value

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!