Java中的賦值運(yùn)算符
自己做了一遍運(yùn)行錯(cuò)誤,于是放到Eclipse上運(yùn)行發(fā)現(xiàn)是int there = one + two; there前沒引用類型,有兩點(diǎn)不能理解的是減等于和除等于和模等于的規(guī)律。。求解
public class HelloWorld{
? ? public static void main(String[] args) {
int one = 10 ;
? ? ? ? int two = 20 ;
? ? ? ? int three = 0 ;
? ? ? ? int there = one + two;
? ? ? ? System.out.println("there = one + two ==>" + there);
? ? ? ? there += one;
? ? ? ? System.out.println("there += one ==>" + there);
? ? ? ? there -= one;
? ? ? ? System.out.println("there -= one ==>" + there);
? ? ? ? there *= one;
? ? ? ? System.out.println("there *= one ==>" + there);
? ? ? ? there /= one;
? ? ? ? System.out.println("there /= one ==>" + there);
? ? ? ? there %= one;
? ? ? ? System.out.println("there %= one ==>" + there);
2018-01-31
int three = one + two ;
把前面那個(gè)int去掉,已經(jīng)定義過three類型了,不用重新定義了
2018-01-25
運(yùn)行好像沒問題啊,代碼應(yīng)該也沒問題,除了three這個(gè)變量沒用到,估計(jì)是打錯(cuò)了吧,不過第二個(gè)變量there也定義了,所以沒問題。
three -= one;????等價(jià)于????three = three - one;
其他的也一樣