I have the following class structure:
public abstract class Generic<T extends SuperClass>
public class SuperGeneric<T extends SuperClass & SomeInterface>
extends Generic<T>
Now I want to make an instance SuperGenericcovering all possible classes. I tried this as follows:
Generic<? extends SuperClass & SomeInterface> myGeneric
= new SuperGeneric<? extends SuperClass & SomeInterface>();
Now it does not work. On Genericit gives the following error Incorrect number of arguments for type Generic<T>; it cannot be parameterized with arguments <? extends SuperClass, SomeInterface>.
And new SuperGenericI get the same error: Incorrect number of arguments for type SuperGeneric<T>; it cannot be parameterized with arguments <? extends SuperClass, SomeInterface>.
Any idea how to instantiate this properly SuperGeneric?
The idea is that I have two different classes that satisfy the condition extends SuperClass & SomeInterface, but they cannot be generalized by the same type.
source
share