public class Demo01 {
public static void main(String[] args) {
int a=2;
int b=a++;//执行完代码后,先给b赋值,再自增
//b=2,a=3
//a=4,c=4
int c=++a;//执行完代码前,先自增,再给c赋值
System.out.println(a);
System.out.println(b);
System.out.println(c);
}
}
2023-09-27 14:30:10
public class Demo01 {
public static void main(String[] args) {
int a=2;
int b=a++;//执行完代码后,先给b赋值,再自增
//b=2,a=3
//a=4,c=4
int c=++a;//执行完代码前,先自增,再给c赋值
System.out.println(a);
System.out.println(b);
System.out.println(c);
}
}