This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
The example seems very puzzling. I can't understand why you are trying to create all those Elements and Sets as member variables of every Element. If you just want to try out extending existing classes, consider the following version of your code:
I also have a few comments... 1. If you actually need a set, then I recommend looking at Sets as provided by the Collections API, in particular the Set interface and the HashSet class. 2. Your set implementation has an apparent "gotcha". Because you use Vector.contains() it will only reject duplicates if the actual object is the same, but not if you try to add a different object with the same name, which is probably what you want. The way round this is to provide an equals(Object) method in your Element class. 3. I have removed your "removeElement" as it was completely redundant - calling the one from Vector works fine.