title: How Do I Remove A Set Of Items Only Once From A List?
body: <p>I have a list that has the items of 2 HashSet within it. I wanted to find the items that appeared in both sets and I wanted to do it by merging the two sets and then since hash sets don't store the same value more than once, remove the hashSet items from the list once.</p>
  
  <p>For instance if i had a list that was: a b b a</p>
  
  <p>and I had a set that was :a b</p>
  
  <p>And i was trying to remove the set from the list I would want the result to be: a b</p>
  
  <p>How do I go about doing this?</p>
  
  <pre><code>Set&lt;String&gt; setItemsA = new HashSet&lt;String&gt;();
  setItemsA.add("a");
  setItemsA.add("b");
  setItemsA.add("c");
  setItemsA.add("d");
  
  Set&lt;String&gt; setItemsB = new HashSet&lt;String&gt;();
  setItemsB.add("a");
  setItemsB.add("b");
  setItemsB.add("RR");
  
  Set&lt;String&gt; setItemsC = new HashSet&lt;String&gt;();
  List&lt;String&gt; cleanedList = new ArrayList&lt;&gt;();
  Set&lt;String&gt; mergedList = new HashSet&lt;String&gt;();
  cleanedList.addAll(setItemsA);
  cleanedList.addAll(setItemsB);
  mergedList.addAll(cleanedList);
  
  System.out.println(cleanedList);
  cleanedList.removeAll(mergedList);
  System.out.println(cleanedList);
  </code></pre>
  
  <p>Currently I am getting an empty list because the Hashset is removing all my items form the list but I only want the items that are in the list that match the hashset to be removed, and if there is a second occurance within the list, for it not to be removed.</p>