I want to create a Java class with two generic types.
public class BinaryContractInfo<T, U>
The thing is that I would like U to be either the same type of T or T[].
Basically I would like to know if T extends T[] or vice versa. Then I could do something like
public class BinaryContractInfo<T, U extends T[]>
Is that possible? Is there a way to do that?
You cannot specify a type as being either
TorT[]Instead you can use varargswhich can be called either
For return types you can specify
if the caller assumes there is only one return value