The code doesn't compile and it is fine, but if I change the code to,
And changing Person's class to
then the answer is A,B,C,E but I thought it should be A,B,C,D since Person overrides equals() and hashcode() and mutually comparable then how come duplicates are added to Set. Am I missing something here? Thanks.