qq_賣火菜的小孩_0
2016-03-23 13:34:06
public class HelloWorld{? ? public static void main(String[] args) { ? ?int one = 10 ;? ? ? ? int two = 20 ;? ? ? ? int three = 0 ;? ? ? ? int three=one+two;? ? ? ? int three+=one;? ? ? ? int three-=one;? ? ? ? int three*=one;? ? ? ? int three/=one;? ? ? ? int three%=one;? ? ? ? System.out.println("three=one+two==>;"+three);? ? ? ? System.out.println("three+=one==>;"+three);? ? ? ? System.out.println( "three-=one==>;"+three);? ? ? ? System.out.println("three*=one==>;"+three);? ? ? ? System.out.println("three/=one==>;"+three);? ? ? ? System.out.println("three%=one==>;"+three);? ? ? ??? ? ? ??
7 回答
已采納

loren_ll
TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超0個(gè)贊
1.代碼不完整 缺少花括號(hào);
2.雙引號(hào)中的代碼,程序只會(huì)原樣輸出,并且,你這個(gè)都是計(jì)算完了再輸出,所以這6個(gè)打印出的都是最后一個(gè)three的值:0
3.最好自己在編譯器中運(yùn)行看看.

卓戈卡奧
TA貢獻(xiàn)8條經(jīng)驗(yàn) 獲得超0個(gè)贊
請(qǐng)記住,代碼總是一行一行執(zhí)行的,這樣寫不會(huì)得到你想要的結(jié)果。
因?yàn)樵谀爿敵龅臅r(shí)候,上面的每一行代碼都早已經(jīng)執(zhí)行完畢。

qq_一立_0
TA貢獻(xiàn)5條經(jīng)驗(yàn) 獲得超5個(gè)贊
不可以,你應(yīng)該在每次對(duì)three賦值的時(shí)候就把three輸出,你這樣結(jié)果只是把three %= ONE 給輸出了,其他的并沒有輸出

Caballarii
TA貢獻(xiàn)1123條經(jīng)驗(yàn) 獲得超629個(gè)贊
不可以,首先同名變量只能定義一次,其次在同一個(gè)變量上重復(fù)賦值會(huì)把之前的值覆蓋
添加回答
舉報(bào)
0/150
提交
取消