Java Arithmetic Operation '--' operator
<p>I am trying to understand the difference between <code>index = index--;</code> and <code>index=--index;</code> I checked the output of <code>index = index--;</code> assignment in the below code block (first example):</p>

<pre><code>public static void main(String[] args) {
    int index = 10;
    for (int i = 0; i &lt; 10; i++) {
        index = index--;
        System.out.println("Index:" + index);
    }//end of for loop
}// end of main method
</code></pre>

<p>Output:</p>

<pre><code>Index:10
Index:10
Index:10
Index:10
Index:10
Index:10
Index:10
Index:10
Index:10
Index:10
</code></pre>

<p>When I use the <code>index=--index;</code> assignment (second example)</p>

<pre><code>public static void main(String[] args) {
        int index = 10;
        for (int i = 0; i &lt; 10; i++) {
            index = --index;
            System.out.println("Index:" + index);
        }
    }// end of main method
</code></pre>

<p>Output:</p>

<pre><code>Index:9
Index:8
Index:7
Index:6
Index:5
Index:4
Index:3
Index:2
Index:1
Index:0
</code></pre>

<p>I have two questions. In the second example Eclipse throws a warning: assignment <code>index = --index;</code>(The assignment to variable index has no effect) But actually it does have an effect on the variable. It decreases its value by 1. Why does Eclipse gives such a warning message? </p>

<p>In the first example, the variable is not affected by the operation (and Eclipse gives no warning). I wonder why Eclipse has no message, and I don't understand why this assignment has no effect over the variable index <code>index = index--;</code></p>
