hi forum,
yesterday i posted a question regarding removing duplicate objects in arraylist and looking at the replies it seemed to me that hashset will be a better option than arraylist.problem is that i want the contents to be itearated strictly in order of their insertion, but the books say that hashset does not guarantee this.actually i m building a simple web crawler and i want this collection to hold the list of links extracted from a web page.naturally duplicate links should not be entered in the collection and so i posted the previous query regarding removing duplicates.plz help me with the choice of the collection. thanks.

Use a LinkedHashSet instead. It can be iterated over in insertion order, but is of course heavier as it needs to keep track of the insertion order (which it does by backing the Set with a List or array).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.