Reputation: 13
I am trying to implement some code that starts with a parent who has a generic variable, and then the child inherits it.
public class Parent <A>{
private A a;
public Parent (A a){
this.a=a;
}
}
public class Child <A> extends Parent<A>{
private A a;
public Child (A a){
this.a=a;
}
}
I'm getting a compile error stating
constructor Parent in class Parent<A> cannot be applied to given types; A
Upvotes: 1
Views: 52
Reputation: 311393
You need to explicitly invoke the parent's constructor from the child's constructor:
public class Child <A> extends Parent<A> {
public Child (A a) {
super(a);
}
}
Upvotes: 3