title: How to remove duplicates in HashSet?
body: <p>In the below code I have added 5 objects with same data in hashset and I want to eliminate the object with duplicate data and print the object data which are distinct.</p>
  
  <pre><code>public static void main(String[] args) {
  Employee emp1 = new Employee(1,"sandhiya","cse",22);
  Employee emp2 = new Employee(1,"sandhiya","cse",22);
  Employee emp3 = new Employee(1,"sandhiya","cse",22);
  Employee emp4 = new Employee(1,"sandhiya","cse",22);
  Employee emp5 = new Employee(1,"sandhiya","cse",22);
  HashSet&lt;Employee&gt; emps = new HashSet&lt;Employee&gt;();
  emps.add(emp1);
  emps.add(emp2);
  emps.add(emp3);
  emps.add(emp4);
  emps.add(emp5);
  for(Employee e: emps){
      System.out.println(e.id + " "+e.name+" "+e.department+ " "+e.age);
  }
  
  
  }
  </code></pre>