Java Set gets duplicate entry
问题 JavaDoc defines set as : A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2) To verify the same, i created a very simple program: import java.util.HashSet; public class CheckHashSet { public static void main(String[] args) { HashSet<Employee> set = new HashSet<Employee>(); set.add(new Employee(10)); set.add(new Employee(10)); System.out.println(set.size()); System.out.println(new Employee(10).equals(new Employee