關(guān)于賦值運(yùn)算符的問題
任務(wù)的要求是應(yīng)用賦值運(yùn)算符實(shí)現(xiàn):? ?three+=one==>40
然后我看教程寫的:three+=one;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Sytem.out.println("three+=one==>"+three);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 我后面這段搞不明白,three+=one==>+three會(huì)變成three+=one=40的。這個(gè)40是怎么得出來的
2019-11-30
根據(jù)第一步運(yùn)算知道,three 的值是 30,而 one 的值是 10,前面幾節(jié)的內(nèi)容可以知道 three += one 是 three = three + one的簡化表示,那么這時(shí) three 的值就是 30 + 10,不就是 40 嗎?不知道你是哪里沒理解?
2020-02-12
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));
?}
}