public class HelloWorld{ public static void main(String[] args) { int one = 10 ; int two = 20 ; int three = 0 ; int three=one+two; System.out.println("three="+three); int three+=one; System.out.println("three="+three); int three-=one; System.out.println("three="+three); int three*=one; System.out.println("three="+three); int three/=one; System.out.println("three="+three); int three%=one; System.out.println("three="+three); } }
第5行已经将three设为int型了,下面不需要重复定义。