首页 > 移动平台 > 详细

慕课网-安卓工程师初养成-3-3 Java中的赋值运算符

时间:2014-09-07 18:27:55      阅读:318      评论:0      收藏:0      [点我收藏+]

来源:http://www.imooc.com/code/1298

 

赋值运算符是指为变量或常量指定数值的符号。如可以使用 “=” 将右边的表达式结果赋给左边的操作数。

Java 支持的常用赋值运算符,如下表所示:

bubuko.com,布布扣

任务

让我们赶紧来做个练习吧,亲...

请在编辑器中,空白处编写代码,应用赋值运算符实现如下结果:

bubuko.com,布布扣

 

 1 public class HelloWorld{
 2     public static void main(String[] args) {
 3         int one = 10 ;
 4         int two = 20 ;
 5         int three = 0 ;
 6         three = one + two;
 7         System.out.println("three = one + two ==> "+three);
 8         three += one;
 9         System.out.println("three += one ==> "+three);
10         three -= one;
11         System.out.println("three -= one ==> "+three);
12         three *= one;
13         System.out.println("three *= one ==> "+three);
14         three /= one;
15         System.out.println("three /= one ==> "+three);
16         three %= one;
17         System.out.println("three %= one ==> "+three);
18     }
19 }

 

 

慕课网-安卓工程师初养成-3-3 Java中的赋值运算符

原文:http://www.cnblogs.com/chenliting/p/3960597.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!