i++ vs ++i
++i
will increment the value ofi
, and then return the incremented value.i = 1; j = ++i; (i is 2, j is 2)
i++
will increment the value ofi
, but return the original value thati
held before being incremented.i = 1; j = i++; (i is 2, j is 1)
Last updated