The for loop executes the initialization section (the first part in the big parenthesized expression) exactly once before the first execution of the loop.
The test, which is the part in there between the first ; and the 2nd ; gets executed every time we consider going thru the loop, and we enter the loop if the condition there is true.
The update section, after the last ; and before the closing ) gets executed each time thru the loop as if it was a statement at the bottom of the loop.
So the code is equivalent to this (but please don't write it that way except once to prove to yourself it is the same):
Now, if that last line said instead and we removed the first println, you would see what you expect, or if both println's were there, "i=1, 2, i=2, 3, i=3, 4), etc.
However, the value after the line completes execution is the same in either case of ++i or i++
So ++i and i++ have the same net effect in the code you wrote. Some programmers like myself, would argue that ++i is more appropriate, but writing it as i++ does the same thing in terms of controlling the loop. It only makes a difference when the value is directly used in a computation or written out somewhere, in which case ++i means do the increment first before using it, i++ means use the old value for the computation or side effect, and then increment it afterwards. The variable winds up with the same value after we are done in either case.
You get interesting (or possibly surprising behavior) when you have multiple references to a variable that is getting pre- or post-incremented in one expression being evaluated.
You will see problems like that on mock and real certification exams.