求大神解釋下模等于
public class HelloWorld{
??? public static void main(String[] args) {
??????? 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);
??????? }
}
???????
2016-03-17
因?yàn)橹皌hree已經(jīng)被申明了是int類型的變量(同一個(gè)變量不能重復(fù)申明)。再給他賦值就會(huì)直接覆蓋它原來的值。