title: What is the basis of output order Hashset in Java
body: <p>I am trying to print the the content of a Hashset. And it outputs it as  [D, E, F, A, B, C]. I was expecting it to output something like [F, E, D, B, A, C]. Is there a logic behind this?</p>
  
  <pre><code>public class TestSomething {
      public static void main(String[] args) {
          HashSet&lt;String&gt; hashSet = new HashSet&lt;String&gt;();
          hashSet.add("F");
          hashSet.add("E");
          hashSet.add("D");
          hashSet.add("B");
          hashSet.add("A");
          hashSet.add("C");
  
          System.out.println(hashSet.toString())
      }
  }
  </code></pre>