慕粉32
2016-04-20 23:40
three-=one;
System.out.println("three -= one ==> "+three);
three 不是30吗
one是10.
three-=one;为什么不是30-10=20呢?
--------------------------------------------------------
three/=one;
System.out.println("three /= one ==> "+three);
为什么不是30/10=3而是等于30呢
System.out.println("three+=one==>"+(three+=one));//three=30+10=40
System.out.println("three-=one==>"+(three-=one));//three=40-10=30
System.out.println("three*=one==>"+(three*=one));//three=30*10=300
System.out.println("three/=one==>"+(three/=one));//three=300/10=30
System.out.println("three%=one==>"+(three%=one));//three=30%10=0
程序从上到下执行,没执行一步,three就被重新赋值
因为之前执行了一步 three += one; 相当于 three = three + one; 即three现在的值变成了40.
所以再执行three -= one; 此时three的值就是30
Java入门第一季(IDEA工具)升级版
1165552 学习 · 17587 问题
相似问题