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

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

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

16条回答
  •  忘了有多久
    2020-11-22 03:35

    Yes, using ++X, X+1 will be used in the expression. Using X++, X will be used in the expression and X will only be increased after the expression has been evaluated.

    So if X = 9, using ++X, the value 10 will be used, else, the value 9.

提交回复
热议问题