This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
As harsh explained you have no implements your equals method correctly, so when it tests to see if the object is in the set then it get false because h1 doesn't equal h2.
Your s1 and s2 do equal therefore only 1 of them will be added.
So you end up with 3 elements in your set.
There would be three objects in the set h1,h2 and s1. h1 and h2 would not be equal reason being in the equals function it performs equals operation of string with HashTest object. In this comparision, it would always return false as they are different instance.
If you want h1 to be logically equal with h2 if they have the same string then you shall have to tweak the code a bit. You can see the example as mentioned below.It would give two objects in the set.