About Question com.enthuware.ets.scjp.v6.2.286 :
Posted: Mon Dec 28, 2020 9:53 am
Hello,
There is a typo in the explanation:
1. i = ++j; is not same as i = j++; In the case of i = ++j, j is first incremented and then compared with i. While in the case of i = j++;, j is first compared with i and then incremented.
I think, that '=' should be changed to '==', at least because of the text: '... and then compared...'.
However, I think, that the explanation is a bit vague, I mean, probably this is not the explanation for this question, because there is no 'i = ++j' or similar in the question.
Probably this would be a better explanation:
1. i++ == 0 is not the same as ++i == 0. In case of i++ == 0, i is compared first with zero, then incremented. While in the case of ++i == 0, i first incremented, then the incremented value is compared with zero.
There is a typo in the explanation:
1. i = ++j; is not same as i = j++; In the case of i = ++j, j is first incremented and then compared with i. While in the case of i = j++;, j is first compared with i and then incremented.
I think, that '=' should be changed to '==', at least because of the text: '... and then compared...'.
However, I think, that the explanation is a bit vague, I mean, probably this is not the explanation for this question, because there is no 'i = ++j' or similar in the question.
Probably this would be a better explanation:
1. i++ == 0 is not the same as ++i == 0. In case of i++ == 0, i is compared first with zero, then incremented. While in the case of ++i == 0, i first incremented, then the incremented value is compared with zero.