Edited at

i++と++iの違い

More than 3 years have passed since last update.


++iは返り値としてインクリメント後の値を返す

 i = 1;

j = ++i;
(i is 2, j is 2)


i++は返り値としてインクリメント前の値を返す

 i = 1;

j = i++;
(i is 2, j is 1)


参考: What is the difference between ++i and i++