Jacob Sonia wrote:If i want to create exactly like a hashset, what should be my approach
Exact?
I took all the interfaces implemented by HashSet and then I defined a new class MySet promising to implement those interfaces. I then let Eclipse add all missing methods. I also added the expected constructors from HashSet.
When you've implemented all these constructor and methods the MySet class will work exactly like a HashSet. Of course it's best to start small. Start with the default constructor and the add and the contains methods. That will constitute a little mini-HashSet.