if you fix the declaration of i (i assume you did that outside of this code segment), here's what happens...
we print the i=1j=1. then, the j==2
test fails, so we don't break. so, we print i=1, since that print statement is still inside the j-loop.
we then increment j to 2. we pass the j-loop test, and print
i=1j=2.
NOW we pass the j == 2 test, so we break out of the j loop.
i think you believe the
is outside the j-loop, but it's not. here is your code reformatted: