I am working with Java generics. Here is a code example followed by the question.
public class Test<T extends Comparable<T>> {
T data;
public Test(T data) {
this.data = data;
}
public T getData() {
return this.data;
}
}
class MyClass<T extends Comparable<T>> extends Test<T> {
//if I remove this constructor, code will not compile
public MyClass(T data) {
super(data);
}
}
In MyClass, if I do not have the constructor I get the following compile time error:
Implicit super constructor Test<T>() is undefined for default constructor. Must define an explicit constructor
Why does the compiler make me do this?