對(duì)碼輸出的結(jié)果有些不解
? ? ? ? int one = 10 ;
? ? ? ? int two = 20 ;
? ? ? ? int three = 0 ;
? ? ? ? three = one + two;
? ? ? ? System.out.println("three = one + two ==>"+three);
? ? ? ? three += one;
? ? ? ? System.out.println("three += one ==>"+three);
? ? ? ? three -= one;
? ? ? ? System.out.println("three -= one ==>"+three);
? ? ? ? three *= one;
? ? ? ? System.out.println("three *= one ==>"+three);
? ? ? ? three /= one;
? ? ? ? System.out.println("three /= one ==>"+three);
? ? ? ? three %= one;
? ? ? ? System.out.println("three %= one ==>"+three);
輸出的結(jié)果為:
three = one + two ==>30
three += one ==>40
three -= one ==>30
three *= one ==>300
three /= one ==>30
three %= one ==>0
倒數(shù)第二個(gè)結(jié)果不應(yīng)該是3嗎?three/=one不就是三十除十的結(jié)果嗎?怎么是30呢?還有為什么每個(gè)輸出的結(jié)果都是大于輸出的值呢?
2016-10-11
three = one + two; //此時(shí)three=10+20=30
three += one;//此時(shí)three=30+10=40
three -= one;//此時(shí)three=40-10=30
three *= one;//此時(shí)three=30*10=300
three /= one;//此時(shí)three=300/10=30
three %= one;此時(shí)three=30/10的余數(shù)0