Interface Set has method add(E e) and it extends interface Collection.
Interface Collection also has method add(E e)
So why do we need the same method in interface Set , since it already extends interface Collection .
What is the purpose ?
I am stuck with that
The purpose is to tell developers what the method should do.
If you implement your own Set, it can't make you implement it so that it doesn't allow duplicate elements. All it can do is tell you what the method should do. If you don't follow the contract it specifies, you're going to cause problems.