Java 自增运算

public class TestOperator{
    public static void main(String[] args)
    {
        int a = 3;
        int b = a++;   //执行完后,b=3。先给b赋值,再自增。
        int c = ++a;   //执行完后,c=5。先自增,再给b赋值

        System.out.println(a);
        System.out.println(b);
        System.out.println(c);        
    }
}

 

posted @ 2021-02-07 14:09  二两也逍遥  阅读(148)  评论(0)    收藏  举报