Change your subclass cosntructor to:
public class NewClass<T> extends BaseClass<T> {
public NewClass(T value){
super(value);
}
}
If you don't add super(value);
, then compiler will automatically add a super();
, which will chain to a 0-arg
constructor of super class. Basically, your original subclass constructor is compiled to:
public NewClass(T value){
super();
}
Now you can see that, it tries to call 0-arg
super class constructor, which the compiler cannot find. Why? Since in super class, you have provided a 1-arg
constructor, compiler won't add any default constructor there. And hence that error.
You can also avoid this problem by giving an explicit 0-arg
constructor in your super class, in which case, your original sub class code will work fine.