List.remove removes odd elements
<p>It might be something obvious but not able to rationalise the output of this snippet.
Reference: <a href="https://github.com/marhan/effective-java-examples/blob/master/src/main/java/org/effectivejava/examples/chapter07/item41/SetList.java" rel="nofollow">this</a></p>

<pre><code>public class Sample {

    public static void main(String[] args) {
        Set&lt;Integer&gt; set = new TreeSet&lt;Integer&gt;();
        List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();

        for (int i = -3; i &lt; 3; i++) {
            set.add(i);
            list.add(i);
        }
        System.out.println("After adding elements:");
        System.out.println(set + " " + list);

        for (int i = 0; i &lt; 3; i++) {
            set.remove(i);
            list.remove(i);
        }
        System.out.println("After removing elements:");
        System.out.println(set + " " + list);
    }
}
</code></pre>

<p>output:</p>

<p>After adding elements:</p>

<p>[-3, -2, -1, 0, 1, 2] [-3, -2, -1, 0, 1, 2]</p>

<p>After removing elements:</p>

<p>[-3, -2, -1] [-2, 0, 2]</p>

<p>I am expecting:</p>

<p>After removing elements:</p>

<p>[-3, -2, -1] [0, 1, 2] </p>

<p>i.e. list.remove(i) should actually remove 1st ,2nd and 3rd item in the list. fair enough ?</p>
