自增自减运算
1.自增运算:++ 自减运算:–
都是一元运算符
package operator;
public class DemoThree {
public static void main(String[] args) {
// ++自增 --自减 一元运算符
int a = 1;
int b = a++; //先b = a = 1 然后a = a + 1 = 2
System.out.println(a);//2
int c = ++a;//先a = a + 1 = 2 + 1 = 3 然后c = a = 3
System.out.println(a); //3
System.out.println(b);//1
System.out.println(c);//3
}
}