Use arbitrary number of arguments in generic classes - Java

I was wondering if it is possible to use an arbitrary number of arguments in the generics of a class? It is possible to use "..." in methods, so I am wondering if there is a similar way for this in generic classes

Class<T ...>


Something like above.


source to share

1 answer

No, you cannot do this. Each type parameter must be specified separately and must be unique in terms of naming.

For example:

public class SomeClass<A, B, C, D> { .... } //valid

public class SomeClass<A, A, B, B> { .... } //wrong, because the names are not unique




All Articles