Is there a difference between x++ and ++x in java?

后端 未结 16 2419
-上瘾入骨i
-上瘾入骨i 2020-11-22 02:34

Is there a difference between ++x and x++ in java?

16条回答
  •  你的背包
    2020-11-22 03:28

    Yes,

    int x=5;
    System.out.println(++x);
    

    will print 6 and

    int x=5;
    System.out.println(x++);
    

    will print 5.

提交回复
热议问题