问答详情
源自:3-3 Java中的赋值运算符

哪里错了啊

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=one+two==>"+three);

        int three+=one;

         System.out.println("three+=one==>"+three);

         int three-=one;

         System.out.println("three-=one==>"+three);

        int three*=one;

         System.out.println("three*=one==>"+three);

        int three/=one;

         System.out.println("three/=one==>"+three);

        int


three%=one;

       System.out.println("three%=one==>"+three);

  这哪里错了啊

提问者:qq_小白_8 2015-05-19 22:34

个回答

  • Absolute_Duo
    2015-05-19 22:38:40

    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以外其他的three都不用加int,否则会造成重定义的错误