慕移动7058161
2021-08-07 07:36
three -=one为什么等于30?不是应该等于20么?
public class HelloWorld{
public static void main(String[] args) {
int one = 10 ;
int two = 20 ;
int three = 0 ;
three=one+two;
System.out.println(three); //现在three=30
System.out.println(three+=one); //现在three=40
System.out.println(three-=one); //现在three=30
System.out.println(three*=one); //现在three=300
System.out.println(three/=one); //现在three=30
System.out.println(three%=one); //现在three=0
/*
每一次输出都在对three重新赋值然后进行下面的继续运算
不知道这样说合理不
*/
three+=one;
System.out.println("three+=one==>"+three);
//这时候等于40
three-=one;
System.out.println("three-=one==>"+three);
//这时候用上个式子的结果再减one就是40-10也就等于30了
//第一行是说three= one + two ==> +three 所以是等于30
//第二行是说three += one ==> +three 所以是等于40
//第三行是说three -= one ==> +three 所以是用40-10+0=30
Java入门第一季(IDEA工具)升级版
1165523 学习 · 17586 问题
相似问题