我正在通過一個教程,我發現這個操作符,但我不知道它是什麼。Java中的*表示什麼?
int number = Integer.parseInt(tfInput.getText());
number * = number;
tfResult.setText(number +「」);
謝謝。
我正在通過一個教程,我發現這個操作符,但我不知道它是什麼。Java中的*表示什麼?
int number = Integer.parseInt(tfInput.getText());
number * = number;
tfResult.setText(number +「」);
謝謝。
a *= b;
相當於a = a * b;
你可能(也許?)熟悉+=
運營商。所有基本的數學函數都有一個類似的運算符。
+=
:a += b;
相當於a = a + b;
-=
:a -= b;
相當於a = a - b;
*=
:a *= b;
相當於a = a * b;
/=
:a /= b;
相當於a = a/b;
%=
:a %= b;
相當於a = a % b;
並請記@ ruakh的評論:
。請注意,* = B計算一個只有一次,而A = A * B計算它 兩次。 (如果a只是一個變量或字段名稱,那麼這並沒有什麼區別,但是如果它是一個更復雜的表達式,例如f()。x 或fgx,那可能很重要。)
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html –
嘗試用幾個值運行你的代碼,看看你是否能算出來。或者閱讀java教程 – atk