Community
Participate
Working Groups
Build ID: 3.3.0 Steps To Reproduce: See the following two little programs: public static void main(String[] args) { int i = 9; i = i++; System.out.println(i); } public static void main(String[] args) { int i = 9; i = ++i; System.out.println(i); } In the first program the assignment has no effect because the increment only happens *after* the assignment. The program will print 9. In the second program, the assignment does have an effect, printing 10. This is all correct. However, Eclipse puts a yellow squiggle under the assignment in the second, not the first program. That's completely the wrong way around (I think). More information:
*** Bug 228817 has been marked as a duplicate of this bug. ***
In fact: i = i++; has some effect as i has the same value after the assignment than before the assignment even if i was incremented. So the assignment nullifies the increment of i. So this is a side-effect of the assignment. See bug 84480. When writing i = ++i;, the assignment has no effect. Even if the value has changed, you don't actually need the assignment to change the value. ++i; would be enough. See bug 100369. The warning is about the assignment itself, not the fact that the value has changed. Closing as INVALID. Philippe, any further comments?
(In reply to comment #2) > The warning is about the assignment itself, not the fact that the value has > changed. > Closing as INVALID. Ah I guess that makes sense. Sorry. Mea culpa.
Was verified for 3.4M7 by reporter (comment 3)