subclasses of MyClass? Maybe make MyClass abstract and implement the methods concretely within the subclasses. Or don’t even make it abstract, still extend it, and override its methods for the appropriate class. If your problem is passing in the classes appropriately to the methods (e.g. the add method must be able to take in any type of the classes you’ve implemented) then you should pass a generic in and specify that it must be of type MyClass. Since all of your other classes extend MyClass, they can be passed in and manipulated properly since they all share the characteristics of MyClass. I’m not sure if this is the solution you’re looking for.
<E extends MyClass>
Обсуждают сегодня