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

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

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

16条回答
  •  盖世英雄少女心
    2020-11-22 03:28

    With i++, it's called postincrement, and the value is used in whatever context then incremented; ++i is preincrement increments the value first and then uses it in context.

    If you're not using it in any context, it doesn't matter what you use, but postincrement is used by convention.

提交回复
热议问题