ArrayList Duplicate Removal
<p>Here's my code:</p>

<pre><code>public static void deleteDuplicates(ArrayList&lt;String&gt; list){
    ArrayList&lt;String&gt; newList = new ArrayList&lt;String&gt;();
    HashSet&lt;String&gt; set = new HashSet&lt;String&gt;();

    for(int i = 0; i &lt; list.size(); i++){
        set.add(list.get(i));
    }

    newList.addAll(set);
    return newList;
}
</code></pre>

<p>My input for this is the following:</p>

<pre><code>1, 2, 2, 3, 4, 3, 1, 5, 5, 4, 1, 4, 5
</code></pre>

<p>And the output I'm getting is:</p>

<pre><code>3, 2, 4, 1, 5
</code></pre>

<p>Can anyone explain why this is out of order?</p>
