Results 1 to 2 of 2
  1. #1
    jjitss is offline Member
    Join Date
    Nov 2011
    Posts
    5
    Rep Power
    0

    Default HashSet/arraylist

    Hi!

    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...

    Thanks,

    Jjitss

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: HashSet/arraylist

    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.

Similar Threads

  1. Replies: 12
    Last Post: 07-07-2011, 08:49 PM
  2. error in HashSet
    By pooja123 in forum New To Java
    Replies: 3
    Last Post: 04-04-2011, 03:39 PM
  3. HashSet
    By Dayanand in forum New To Java
    Replies: 7
    Last Post: 03-12-2011, 09:37 AM
  4. Getting value for key in HashSet
    By Venny in forum New To Java
    Replies: 12
    Last Post: 02-02-2011, 08:42 AM
  5. :( anyone here plz help on HashSet
    By waklo99 in forum New To Java
    Replies: 8
    Last Post: 09-20-2010, 03:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •