title: Ordering of elements in Java HashSet
body: <p>Why do the second and third sets preserve order: </p>
  
  <pre><code>Integer[] j = new Integer[]{3,4,5,6,7,8,9};
  LinkedHashSet&lt;Integer&gt; i = new LinkedHashSet&lt;Integer&gt;();
  Collections.addAll(i,j);
  System.out.println(i); 
  
  HashSet&lt;Integer&gt; hi = new HashSet&lt;Integer&gt;(i);
  System.out.println(hi); 
  
  LinkedHashSet&lt;Integer&gt; o = new LinkedHashSet&lt;Integer&gt;(hi);
  System.out.println(o); 
  </code></pre>
  
  <p>Here's the output I get:</p>
  
  <pre><code>3,4,5,6,7,8,9
  3,4,5,6,7,8,9
  3,4,5,6,7,8,9
  </code></pre>