Using X++ vs ++x When you use X++ then x is only incremented Code: x = 1; y = x++; //stuff x into y BEFORE incrementing x Means: x = 1; y = x; x = x + 1; Results: x = 2, y = 1 Code: x = 1; y = ++x; //increment x BEFORE stuffing x into y Means: x = 1; x = x + 1; y = x; Results: x = 2, y = 2 ++x == increment x x++ == copy x into a temporary variable, increment x and evaluate the temporary variable. So (++x == 2) will increment x by 1 then see if that new value is equal to 2. (x++ == 2) will copy x into a temporary variable, increment x, then see if the old value of x is equal to 2.