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

我不明白这个

http://img1.sycdn.imooc.com//559798c30001b9b505560481.jpg我不明白为什么这个three一会变成30,一会变成40.是什么意思?如图所示这时候变成40了,到了 *= 的时候又变成30了,请教大神

正在回答

5 回答

three一直在重新赋值啊。

刚开始

int three = 0 ;

这时候three是0;

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

 这时候的值是10+20,是30;

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

  这时候的值是30+10,是40;    

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

   这时候的值是40-10,是30;

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

 这时候的值是30x10,是300;

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

 这时候的值是300/10,是30;

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

 这时候的值是300%20,是0;

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

three-=one

表示:three=three-one;因此three此时就是30啦

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

three *=one

表示three = three*one;

因此three的值是会改变的,这里的 -=,+=,/=,*=,都是符合运算符号,你首先理解他们的含义

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

没明白,我是说这个three的值一直是3吗,还是会变。

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

a*=b:a=a*b完全没问题呀,其他类似

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

举报

0/150
提交
取消
Java入门第一季(IDEA工具)升级版
  • 参与学习       1163399    人
  • 解答问题       17551    个

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

进入课程

我不明白这个

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