Weird HashSet behavior with larger values : <p>I found a (for me) inexplicable behavior with an implemented HashSet in Java. I implemented the HashSet like this and filled it with the values of a list.</p>

<pre><code>HashSet&lt;Integer&gt; set = new HashSet&lt;Integer&gt;(list);
</code></pre>

<p>I first used a list containing numbers reaching fom 0 to 9 to fill the HashSet:</p>

<p>Example:   <code>{1,0,5,9,6,7,3,1,3,6,1,5,1,3,4,9,9,7}</code><br>
Output:    <code>[0, 1, 3, 4, 5, 6, 7, 9]</code></p>

<p>Since HashSets normally give back values in an ascending sorted order until now everything worked fine. But as soon as I started using a list containing bigger vaues it starts giving back the values in a weird way:</p>

<p>Example: <code>{67,1,122,19,456,42,144,42,3,34,5,5,42}</code><br>
Output: <code>[1, 34, 67, 3, 5, 456, 42, 144, 19, 122]</code></p>

<p>I read something about that this depends on the internal hashing algorithm here: <a href="https://stackoverflow.com/questions/16737229/java-hashset-shows-list-in-weird-order-always-starting-with-3][1]">Java HashSet shows list in weird order, always starting with 3</a> but that is even more confusing since I used the exact same HashSet just with different values.</p>

<p>Could please somebody explain me why this is happening?</p>
