Unchecked cast from Object to Compareable<Object>
インスタンスが Compareable 型の場合、入力のみの領域内にあるため、なぜ を取得するのかわかりません。誰かが私にこれを説明して、おそらく解決策を教えてもらえますか?
私のコードは次のようになります。問題は 8 行目と 9 行目です。
public int compare(Object one, Object two) {
if (one instanceof Vector && two instanceof Vector) {
Vector<? extends Object> vOne = (Vector<?>)one;
Vector<? extends Object> vTwo = (Vector<?>)two;
Object oOne = vOne.elementAt(index);
Object oTwo = vTwo.elementAt(index);
if (oOne instanceof Comparable && oTwo instanceof Comparable) {
Comparable<Object> cOne = (Comparable<Object>)oOne;
Comparable<Object> cTwo = (Comparable<Object>)oTwo;
if (ascending) {
return cOne.compareTo(cTwo);
} else {
return cTwo.compareTo(cOne);
}
}
}
return 1;
}