不能理解,為什么three在下一行的值會變成上一行的值
package com.wolike;
public class 試題8賦值運算符 {
public static void main(String[] args){
int one=10;
int two=20;
int three=30;
System.out.println("three=one+two==>"+(two+one));
System.out.println("three+=one==>"+(one+three));
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));
}
}
最后輸出的是:
three=one+two==>30
three+=one==>40
three*=one==>300
three/=one==>3
three-=one==>20
three%=one==>0
2019-01-01
你這three的賦值是30,源代碼中是0,另外你的代碼沒有將three重新賦值,所以three始終是30,并沒有像你說的那樣“下一行的值會變成上一行的值”。
2019-01-01
因為你發的代碼沒有將three重新賦值,所以你的運算結果永遠是用one和two這兩個變量進行計算,計算結果肯定跟任務中要求的結果不一樣。
2018-12-11
多去看看2-4的課。就能理解
2018-11-26
不好意思,發錯了