java_赋值运算符
1 class OperateDemo2 2 { 3 public static void main(String[] args) 4 { 5 /* 6 赋值运算符 7 = += -= *= /= %= 8 9 10 int a,b,c; 11 a= b = c = 4; 12 int x = 5;//赋值运算 右边赋值给左边 13 x += 2; //将左右两边的和赋值给左边 x = x +2*/ 14 short s =3; 15 s = s + 6;//编译失败 16 s += 6; //编译通过,因为+=是赋值运算,会有一个自动转换动作 17 18 System.out.println("a="+a+"b="+b); 19 } 20 }