薄荷波
2016-03-17 19:05
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);
}
}
因为之前three已经被申明了是int类型的变量(同一个变量不能重复申明)。再给他赋值就会直接覆盖它原来的值。
Java入门第一季(IDEA工具)升级版
1165172 学习 · 17581 问题
相似问题