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

赋值运算符的除等于 求大神解答??

如示例 int one = 10 ;

       int two = 20 ;

       int three = 0 ;

       three = one + two;

       System.out.println("there = 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);

输出的结果是

there = one + two ==>30

three += one ==>40

three -= one ==>30

three *= one ==>300

three /= one ==>30

three %= one ==>0

我想问一下当除等于的时候为什么是30 而不是3 根据示例说明 C/=A 相当于 C=C/A 。

或者在*=的时THREE的值已经变成了 300 才导致除等于是30的吗?? 求大神解答???

提问者:QTIN 2016-03-15 23:12

个回答

  • 慕设计8024997
    2016-03-15 23:24:44
    已采纳


    three = 300;
    one = 10;
    three /= one;//相当于 three = three / one; 相当于 three = 300 / 10; 所有就是30


  • qq_吾心常在_0
    2016-03-15 23:28:09

    这里的 = 是赋值号     ==才是等号

  • BOBO_0003
    2016-03-15 23:25:53

    three在*=的时候值已经变成了300