Why doesn't `index = index++` increment `index`?
<p>** Dup: <a href="http://stackoverflow.com/questions/226002/whats-the-difference-between-x-x-vs-x">http://stackoverflow.com/questions/226002/whats-the-difference-between-x-x-vs-x</a> **</p>

<p>So, even though I know you would never actually do this in code, I'm still curious:</p>

<pre><code>public static void main(String[] args) {
    int index = 0;
    System.out.println(index);   // 0
    index++;
    System.out.println(index);   // 1
    index = index++;
    System.out.println(index);   // 1
    System.out.println(index++); // 1
    System.out.println(index);   // 2
}
</code></pre>

<p>Note that the 3rd <code>sysout</code> is still <code>1</code>. In my mind the line <code>index = index++;</code> means "set index to index, then increment index by 1" in the same way <code>System.out.println(index++);</code> means "pass index to the println method then increment index by 1".</p>

<p>This is not the case however. Can anyone explain what's going on?</p>
