為什么這樣不可以,但是分開步驟就可以???
public static void main(String[] args) {
? ? int one = 10 ;
? ? ? ? int two = 20 ;
? ? ? ? int three = 0 ;
? ? ? ? System.out.println("three=one+two==>"+(one+two));
? ? ? ? System.out.println("three+=one==>"+(three+=one));
public static void main(String[] args) {
? ? int one = 10 ;
? ? ? ? int two = 20 ;
? ? ? ? int three = 0 ;
? ? ? ? System.out.println("three=one+two==>"+(one+two));
? ? ? ? System.out.println("three+=one==>"+(three+=one));
2019-09-02
舉報
2019-11-01
因為你在第一步int three=0的時候定義變量three=0 這是第一個three,如果分開寫的話你每一個three都是不同的,比如說你定義的第一個那個three=0,但是在第一步變換three=one+two時,就變成了第二個three=30,接下來以此類推,但是如果你連起來寫的話你的每一個three都是初始值three=0,這樣解釋能明白嗎
2019-10-07
寫法沒有錯,但是運行結(jié)果是不對的。因為three這個變量沒有進行賦值這個步驟。
2019-09-03
上面一個輸出30,下面一個是10
2019-09-02
要先聲明變量吧
2019-09-02
沒太看明白你的意思,""號里面的內(nèi)容是原樣輸出的,“”外面的內(nèi)容是做計算后拼接的