ジェネリック クラス Storage と、もう 1 つのジェネリック クラス StoragePlus があります。以下の太字のコメントのある行で、境界エラーの不一致エラーが発生します。
これが最初のクラスのコードです。
public class Storage<T extends Comparable<? super T>> {
//private T t;
private T[] isafe;
public int max;
private int nextIndex;
public Storage(int maxNum, T[] seedArr){
if(maxNum < 0){
throw new IllegalArgumentException();
}
else{
isafe = Arrays.copyOf(seedArr, maxNum);
nextIndex = 0;
max = maxNum;
}
}
これが 2 番目のクラスのコードです。
public class StoragePlus <T> extends Storage<T>{ **//getting an error here**
public StoragePlus(int maxNum, T[] arr){
super(maxNum,(Comparable[]) arr);
}
@Override
public boolean equals(Object obj){
if(obj == null|| obj.getClass() != this.getClass()){
return false;
}
else{
if(obj == this){
return true;
}
else{
@SuppressWarnings("unchecked")
Storage<?> temp = (Storage<T>) obj; **// also getting an error here**
}
}
}
}