似乎不是通用数组的通用数组错误

时间:2018-09-26 20:37:30

标签: java arrays eclipse templates generics

我收到通用数组错误,但是我不认为我正在尝试实例化通用数组。数组的类型为Double,这意味着它不应该是通用的,不是吗?

public class PolynomialSet extends Set<Polynomial<Double>>{
    public PolynomialSet(int size){
        elements = new Polynomial<Double>[size];
}

public class Polynomial <Domain> {}

public class Set<Type> {

    protected Type[] elements;
    protected int cardinality;

    public int size(){
        return elements.length;
    }
    public Type get(int k){
        return elements[k];
    }
    public void set(int k, Type in){
        elements[k]=in;
    }

}

0 个答案:

没有答案