title: Adavantages of HashSet over ArrayList and vice versa
body: <p>I have a doubt regarding data structures in Java. While solving a typical hashing problem in Java, I was using the <strong><code>HashSet</code></strong> data structure, which worked fine until there were duplicate objects (object contents). Since HashSet does not support insert of duplicates, my logic was failing.</p>
  
  <p>I replaced the hashset with the typical <strong><code>Arraylist</code></strong> since the methods of hashset such as <em>.add()</em>, <em>.contains()</em>, <em>.remove()</em> are supported in both, and my logic worked perfectly then.</p>
  
  <p>But does this necessarily mean ArrayList is the logical choice over Hashset when duplicates are involved? There should be some time complexity advantages of Hashset over ArrayList right? Can someone please provide me some insight regarding this?</p>
  
  <p><strong>EDIT:</strong> What would be the ideal data structure when you want to do hashing when duplicates are involved. I mean when the duplicates should not be ignored and should be inserted.</p>