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

对%的计算结果的疑问

 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的结果是0呢,three此时为30,30%10因该为3才对啊

提问者:舵 2017-04-03 17:55

个回答

  • 慕粉1054401865
    2017-04-03 18:31:54
    已采纳

    %是取余,30除以10的余数是0!!!并不是3!!!!1