Hi I will be storing URLs in a collection. But I don't want to have duplicate URLs in my collection. I have read that ArrayLists or LinkedLists can contain duplicate items so i think I should abstain from them. I think I should use sets, but am sure which one to use. I can't work out which one would be more efficient? I suppose I could also check through my collection using the .contains() method. Any advice please?
Since you probably don't need to keep the URLs sorted in some particular order, don't use TreeSet, which adds this ability, but at the cost of some performance. HashSet is usually your best bet.
Here's my crib sheet on collections: http://www.surfscranton.com/architecture/JavaCollections.htm I know there are other criteria to help choose which one to use. If you have other advice, lemme know and I'll add to this. Frinstance, I should mention that LinkedHashMap retains insertion order.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
Gift giving made easy with the permaculture playing cards