Hope this explanation may be helpful:
j = i++; // Here since i is post incremented, so first i being 0 is assigned to j // and after that assignment , i is incremented by 1 so i = 1 and j = 0. i = i++ + f1(i); // here again since i is post incremented, it means, the initial value // of i ie 1 as in step shown above is used first to solve the // expression i = i(which is 1) + f1(1)**Since i is 1** // after this step the value of i is incremented. so i now becomes 2 // which gets displayed in your last System.out.println(i) statement.
try it
i = ++i + f1(i);
So, a short time in incremental increment expression is first resolved, and then the value increases. But in pre increment, the value first increases, and then the expression is resolved.
But if you write only
i++; ++i;
Then both mean the same thing.
Hi
nIcE cOw
source share