Results 1 to 2 of 2
- 11-14-2011, 12:58 AM #1Member
- Join Date
- Nov 2011
- Rep Power
I programmed a 'collection' ADT. For the implementation of my collection I used a HashSet (with an iterator) because the kind of collection I
programmed, has no structure in ordening. My teammate is convinced that a collection better can be implemented with an arraylist. And my question is: In this case, is there anything I missed with the implemention of a collection with a hashset?
I hope a more advanced programmer, then myself, can review this problem...
I'm not advanced in this regard, but I believe that if your collection will not allow duplicates, and the items held in the collection have well defined and behaved hashCode and equals methods, then a HashSet is fine. An ArrayList is good if you want a collection that allows duplicates and where you want code that is optimized to obtain items in a random access way and by an index.
- By ralf in forum New To JavaReplies: 12Last Post: 07-07-2011, 08:49 PM
- By pooja123 in forum New To JavaReplies: 3Last Post: 04-04-2011, 03:39 PM
- By Dayanand in forum New To JavaReplies: 7Last Post: 03-12-2011, 10:37 AM
- By Venny in forum New To JavaReplies: 12Last Post: 02-02-2011, 09:42 AM
- By waklo99 in forum New To JavaReplies: 8Last Post: 09-20-2010, 03:02 AM