hi Phil ,
here is the code that it should look like
what is happening is that the the HashSet overrides the hashcode() and equals() method ,so if you try to put duplicate elements in a HashSet it would be considered as a single value and only one of them will exist ,therefore when we delete 1 there is only one element left and that is 2 and if we remove that also we get size of set as zero,it is one of the reasons why set is different from lists which can contain duplicate elements.
Btw when you comment the hashCode() method (use the default method) then all your objects will be in the same bucket .Now compile and run it .Then you will see the expected answer.
[Bsc in Computer Science and Engineering] [SCJP 80%][BCS certificate level]
Cob is sand, clay and sometimes straw. This tiny ad is made of cob: