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

关于赋值运算符的问题

任务的要求是应用赋值运算符实现:   three+=one==>40

然后我看教程写的:three+=one;

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

                              我后面这段搞不明白,three+=one==>+three会变成three+=one=40的。这个40是怎么得出来的

正在回答

2 回答

根据第一步运算知道,three 的值是 30,而 one 的值是 10,前面几节的内容可以知道 three += one 是 three = three + one的简化表示,那么这时 three 的值就是 30 + 10,不就是 40 吗?不知道你是哪里没理解?

1 回复 有任何疑惑可以回复我~
#1

努力学习的白 提问者

已经理解了 没事了 谢谢。
2019-12-01 回复 有任何疑惑可以回复我~
#2

慕少1317773

three -= two; System.out.println("three -= two ==>"+three); 那按你说的,应该是30-20=10 你解释这个为什么会是20 ?
2020-03-24 回复 有任何疑惑可以回复我~

public class HelloWorld{
    public static void main(String[] args) {
     int one = 10 ;
        int two = 20 ;
        int 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
提交
取消
Java入门第一季(IDEA工具)升级版
  • 参与学习       1166339    人
  • 解答问题       17590    个

0基础萌新入门第一课,从Java环境搭建、工具使用、基础语法开始

进入课程

关于赋值运算符的问题

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号