1. 程式人生 > >Java中的賦值運算符

Java中的賦值運算符

結果 out sta ima spa 操作數 color info 慕課

賦值運算符是指為變量或常量指定數值的符號。如可以使用 “=” 將右邊的表達式結果賦給左邊的操作數。

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 }

摘自:慕課網

Java中的賦值運算符