2
私が持っているこのインタフェースJavaのコレクションは、同等の拡張インターフェイスを拡張ジェネリッククラスを比較
public interface IDataPoint<T> extends Comparable<T> {
public T getValue();
}
と、この実装...
public class IntegerDataPoint implements IDataPoint<Integer> {
// ... some code omitted for this example
public int compareTo(Integer another) {
// ... some code
}
}
と別のクラス...
public class HeatMap<X extends IDataPoint<?> {
private List<X> xPoints;
}
今度はxPoints
リストでCollections.max(など)を使用したいと思っていますが、これは機能しませんが、おそらく私のジェネリック医薬品がすべて乱されたからです。
解決方法(Comparator
なし)を教えてください。
Collections.max(xPoints);
は私に、このエラーを与える:
Bound mismatch: The generic method max(Collection<? extends T>) of type Collections is not applicable for the arguments (List<X>). The inferred type X is not a valid substitute for the bounded parameter <T extends Object & Comparable<? super T>>
「うまくいかない」とはどういう意味ですか? compareToは呼び出されていませんか? –
「動作しません」と定義してください。 – Vincent
詳細を追加しました... – Mickel