在IDEA中,int a=0;a=a+0.1;会报错,但是为什么int a=0;a+=0.1;不会报错?还能运行成功?
a+=0.1 等价于 a=(int)(a+0.1)
a=a+0.1;报错是因为a+0.1是浮点类型,赋值给int类型需要强转。