What is the difference between pre-increment and post-increment in the cycle (for/while)?
问题 My interest is in the difference between for and while loops. I know that the post-increment value is used and then incremented and the operation returns a constant pre-increment. while (true) { //... i++; int j = i; } Here, will j contain the old i or the post-incremented i at the end of the loop? 回答1: Since the statement i++ ends at the ; in your example, it makes no difference whether you use pre- or post-increment. The difference arises when you utilize the result: int j = i++; // i will