为了账号安全,请及时绑定邮箱和手机立即绑定

这样写是不是绕路了

public class HelloWorld{

    public static void main(String[] args) {

    int one = 10 ;

        int two = 20 ;

        int three = 0 ;

        int aa= one + two;

        int bb= (three+=one);

        int cc= (three-=one);

        int dd= (three*=one);

        int ee= (three/=one);

        int ff= (three%=one);

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

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

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

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

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

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

}

}


正在回答

2 回答

你这样是错的,赋值运算符计算后是会赋值的,会把计算的值赋给three,你只有后面的three值一直都没变,与题意不符,题意是每运算一次赋值给three,然后进行下一次运算

0 回复 有任何疑惑可以回复我~

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

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

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

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

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

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

  


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

这样写是不是绕路了

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信