赋值运算符就是将某个运算后的值,赋给指定的变量。
package demo02;
public class Assignment {
public static void main(String[] args) {
//+=
int a = 10;
a += 1;
System.out.println(a);//11
//-=
a -= 2;
System.out.println(a);//9
//*=
a *= 2;
System.out.println(a); //18
// /=
a /= 4;
System.out.println(a); //4
}
}
二、注意事项
1、运算顺序从右往左
2、赋值运算符的左边只能是变量,右边可以是变量、表达式、常量值
3、 复合赋值运算符会进行类型转换。



