私はこのインターフェースを持っています
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;
}
リストでCollections.max(および同様のもの)を使用したいのxPoints
ですが、ジェネリックがすべて台無しになっているためか、それは機能しません。
これを(なしで)どのように解決できるかについての提案はあります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>>