简体   繁体   中英

How to call to parent constructor of generic class

I have a class A and a class B which extends A

public class A<T1, T2> {

    private T1 x;
    private T2 y;

    public A(T1 x, T2 y) {
        this.x = x;
        this.y = y;
    }
}

The above code works fine, now for class B

public class B<T1,T2,T3> extends A {
    private T3 z;

    public Triplet(T1 x, T2 y, T3 z) {
        super(x, y);
        this.z = z;
    }
}

Eclipse gives the following warning on this code:

Type safety: The constructor A(Object, Object) belongs to the raw type A. References to generic type A should be parameterized

What does this mean, is my super call incorrect or something else?

您需要指定您的父类泛型

public class B<T1,T2,T3> extends A<T1,T2> {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM