title: How to get the elements in correct order from iterator()
body: <p>Here is my code to store the data into HashMap and display the data using iterator</p>
  
  <pre><code>public static void main(String args[]) {
      HashMap&lt;String, String&gt; hm = new HashMap&lt;String, String&gt;();
      hm.put("aaa", "111");
      hm.put("bbb", "222");
      hm.put("ccc", "333");
      hm.put("ddd", "444");
      hm.put("eee", "555");
      hm.put("fff", "666");
  
      Iterator iterator = hm.keySet().iterator();
  
      while (iterator.hasNext()) {
          String key = (String) iterator.next();
          String val = hm.get(key);
  
          System.out.println(key + " " + val);
      }
  }
  </code></pre>
  
  <p>But it is not displaying in the order in which I stored. Could someone please tell me where am I going wrong?  How can I get the elements in the order? </p>