为啥int定义过的不能在再添加int定义?
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=one+two前面不用加上int,是因为前面已经定义过了,不用打上去。
那我有个疑问,那为啥打上去int会报错?看起来即时打上int也不会影响算法,那为什么会报错?求各位指教。