title: How to remove duplicates in the Java HashSet
body: <p>I have a set of this structure. How to remove duplicates of equal object of that class? Equals means field File plik is the same.</p>
  
  <p><strong>EDIT:
  But the problem gut bigger I don't have duplicates but I would like to replace old SET member by new.</strong></p>
  
  <p><em><strong>Withoud 3rd party libraries.</em></strong></p>
  
  <pre><code>import java.io.*;
  
  public class WordInfo implements Serializable {
      File plik;
      Integer wystapienia;
  
      public WordInfo(File plik, Integer wystapienia) {
          this.plik = plik;
          this.wystapienia = wystapienia;
      }
  
      public String toString() {
      //  if (plik.getAbsolutePath().contains("src") &amp;&amp; wystapienia != 0)
              return plik.getAbsolutePath() + "\tWYSTAPIEN " + wystapienia;
      //  return "";
      }
  
  }
  </code></pre>
  
  <h2>EDIT</h2>
  
  <p>I don't have this HashCodeBuilder I want to use Java standard libraries</p>
  
  <pre><code> public int hashCode() {
              return new HashCodeBuilder(17, 31).append(plik).append(wystapienia).toHashCode();
          }
  
      public boolean equals(Object obj) {
          File f = (File) obj;
          return(plik.getAbsoluteFile().equals(f.getAbsolutePath()));
      }
  </code></pre>