title: Compare two set and remove common items
body: <p>I have two sets which contain some elements as object. I want to remove common element from the set. How can I remove common elements from set?</p>
  
  <pre><code>Set&lt;AcceptorInventory&gt; updateList = new HashSet&lt;AcceptorInventory&gt;();
  Set&lt;AcceptorInventory&gt; saveList = new HashSet&lt;AcceptorInventory&gt;();
  </code></pre>
  
  <p>Both sets have some items, the <code>saveList</code> have duplicated items &amp; I wish to remove duplicated items from <code>saveList</code>. I tried with <code>foreach</code> loop, but it did not work.</p>
  
  <p><strong>Sample output:</strong></p>
  
  <pre><code>save 5
  save 20
  save 50
  save 10
  update 5
  update 10
  update 20
  </code></pre>
  
  <p>AcceptorInventory Hashcode and equals</p>
  
  <pre><code>@Override
  public int hashCode() {
      final int prime = 31;
      int result = 1;
      result = prime * result + count;
      result = prime * result
              + ((currency == null) ? 0 : currency.hashCode());
      result = prime * result + ((date == null) ? 0 : date.hashCode());
      result = prime * result + (int) (id ^ (id &gt;&gt;&gt; 32));
      result = prime * result + (isCleared ? 1231 : 1237);
      result = prime * result
              + ((kioskMachine == null) ? 0 : kioskMachine.hashCode());
      result = prime * result + ((time == null) ? 0 : time.hashCode());
      long temp;
      temp = Double.doubleToLongBits(total);
      result = prime * result + (int) (temp ^ (temp &gt;&gt;&gt; 32));
      return result;
  }
  
  @Override
  public boolean equals(Object obj) {
      if (this == obj)
          return true;
      if (obj == null)
          return false;
      if (getClass() != obj.getClass())
          return false;
      AcceptorInventory other = (AcceptorInventory) obj;
      if (count != other.count)
          return false;
      if (currency == null) {
          if (other.currency != null)
              return false;
      } else if (!currency.equals(other.currency))
          return false;
      if (date == null) {
          if (other.date != null)
              return false;
      } else if (!date.equals(other.date))
          return false;
      if (id != other.id)
          return false;
      if (isCleared != other.isCleared)
          return false;
      if (kioskMachine == null) {
          if (other.kioskMachine != null)
              return false;
      } else if (!kioskMachine.equals(other.kioskMachine))
          return false;
      if (time == null) {
          if (other.time != null)
              return false;
      } else if (!time.equals(other.time))
          return false;
      if (Double.doubleToLongBits(total) != Double
              .doubleToLongBits(other.total))
          return false;
      return true;
  }
  </code></pre>