title: Is there any way to get the items from HashSet in insertion order in java?
body: <p>Our existing code using HashSet to store data's.I know Nature of the Set interface is giving random order.But i need the same insertion order.Is there any way to get the insertion order from the set???</p>
  
  <p>Please guide me get out of this issue?</p>
  
  <p>I also used LinkedHashSet, it also giving elements in some other order and not insertion order that i wanted...</p>
  
  <pre><code>Set attachmentSet=new HashSet();
          attachmentSet.add("dfsdfsd");
          attachmentSet.add("erwerwer");
          attachmentSet.add("vcvcvcv");
          attachmentSet.add("ytytyt");
  
          Iterator attachItr=attachmentSet.iterator();
          while(attachItr.hasNext())
          {
              System.out.println("SET Item::"+attachItr.next());
          }
  
  LinkedHashSet newCopy = new LinkedHashSet();
          newCopy.add("dfsdfsd");
          newCopy.add("erwerwer");
          newCopy.add("vcvcvcv");
          newCopy.add("ytytyt");
          Iterator attachItr2=copy.iterator();
          while(attachItr2.hasNext())
          {
              System.out.println("NEW LinkedHashSet Item::"+attachItr2.next());
          }
  </code></pre>