Java中的赋值运算符

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

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

 

 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     
20     }
21 }

 

 

摘自:慕课网

posted @ 2018-08-01 17:30  HkGov  阅读(429)  评论(0编辑  收藏  举报