Java中的賦值運算符
阿新 • • 發佈:2018-08-01
結果 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中的賦值運算符