Should a HashSet be allowed to be added to itself in Java?

Others have already pointed out why it is questionable from a mathematical point of view, by referring to Russell’s paradox. This does not answer your question on a technical level, though. So let’s dissect this: First, once more the relevant part from the JavaDoc of the Set interface: Note: Great care must be exercised if … Read more