How can I retrieve the items in my HashSet / HashMap in the order they were added?

John Zukowski

Prior to Java 1.4, you had to manage a separate insertion order list yourself. Starting with Java 1.4, you can use the new LinkedHashMap / LinkedHashSet classes. The iterators you get back from them return the items in insertion order.