求大神解釋下模等于
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
因為之前three已經被申明了是int類型的變量(同一個變量不能重復申明)。再給他賦值就會直接覆蓋它原來的值。