I have a classes defined as so:
public abstract class AbstractUploadField<T> {
And
public class GroupField<T> extends AbstractUploadField<T> {
Then in Java I am trying to use generics to make sure a class is a subclass of AbstractUploadField
Class<? extends AbstractUploadField<?>> clazz = GroupField.class
The above does not compile, but if I remove the second wildcard it does:
Class<? extends AbstractUploadField> clazz = GroupField.class
I don’t understand why the first assignment wouldn’t work
GroupFieldandAbstractUploadFieldshould both have the same generic typeTIn the line
The first wildcard can be different from the second wildcard which contradicts the first statement.
The statement:
works but I assusme you are getting a warning for it.