努力学习的白
2019-11-29 22:32
任务的要求是应用赋值运算符实现: three+=one==>40
然后我看教程写的:three+=one;
Sytem.out.println("three+=one==>"+three);
我后面这段搞不明白,three+=one==>+three会变成three+=one=40的。这个40是怎么得出来的
根据第一步运算知道,three 的值是 30,而 one 的值是 10,前面几节的内容可以知道 three += one 是 three = three + one的简化表示,那么这时 three 的值就是 30 + 10,不就是 40 吗?不知道你是哪里没理解?
public class HelloWorld{
public static void main(String[] args) {
int one = 10 ;
int two = 20 ;
int three = 0 ;
System.out.println("three = one + two ==>"+ (three=one+two));
System.out.println("three += one ==>"+ (three+=one));
System.out.println("three -= one ==>"+ (three-=one));
System.out.println("three *= one ==>"+ (three*=one));
System.out.println("three /= one ==>"+ (three/=one));
System.out.println("three %= one ==>"+ (three%=one));
}
}
Java入门第一季(IDEA工具)升级版
1165550 学习 · 17586 问题
相似问题