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

代码错误4

int one = 10 ;
        int two = 20 ;
        int three = 0 ;
        three=one+two;
        three+=one;
        three-=one;
        three*=one;
        three/=one;
        three%=one;
        System.out.println("three=one+two==>"+three);
        System.out.println("three+=one==>"+three);
        System.out.println("three-=one==>"+three);
        System.out.println("three*=oneo==>"+three);
        System.out.println("three/=one==>"+three);
        System.out.println("three%=one==>"+three);


  输出不对  都是0

提问者:承诺太虚伪 2017-04-20 22:31

个回答

  • 森之南1234
    2017-04-28 00:30:40

    http://img.mukewang.com/59021c670001b13206640404.jpg

    重新实验的结果

  • 森之南1234
    2017-04-27 22:02:38

       int one = 10 ;

            int two = 20 ;

            int three = 0 ;

        System.out.println(three=one+two);

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

        System.out.println(three-=one);    

        System.out.println(three*=one);    

        System.out.println(three/=one);    

        System.out.println(three%=one);    

            

    简单点这样不就行了,你那个为啥都是0,评论里有个哥们说了啦,那样写相当如不断重复赋值给three(最后一个three%=one;的结果为0),所以你输出的都是three=0(除开前面带的字符)

  • 緋翼
    2017-04-21 01:39:44

    我建议改为这样,就会有你想要的结果啦!!!http://img.mukewang.com/58f8f255000109f305470376.jpg

  • 承诺太虚伪
    2017-04-20 22:40:33

    为什么要分开呢 ?不分开 他会用哪个呢