Those are two different things
x++
is a post-increment. It returns x
before the change but then changes it:
tmp = x;
x = x+1;
return tmp;
whereas
++x
is a pre-increment. It first changes x
and returns the new value afterwards:
x = x+1;
return x;
The second one is also slightly faster as your compliler/interpreter doesn't need to create a temporary variable and copy the data across.