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

求大佬解释

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 -= 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);                                        如上:第10行和11行,three -= one;                           按等价应该是three=three-one                          也就是30-20 = 10                                                    为什么输出是three -= two ==>30

提问者:慕少1317773 2020-03-24 13:12

个回答

  • 慕娘2046425
    2020-05-06 11:24:42

    你后面打印的是three-=two,但前面做的却是three-=one,

    实际上是40-10=30,所以打印出来的也是30.