假设我有一个 java 类
public class Foo<ELEMENT, COMPARATOR extends Comparator<ELEMENT>> {
public Foo(ELEMENT e, COMPARATOR c) {...}
}
如何重新加载类型参数<ELEMENT>
,以便我也可以拥有类似的东西
public class Foo<ELEMENT extends Comparable> {
public Foo(ELEMENT e) {
this(e, new Comparator<ELEMENT>() {
public int compare(ELEMENT e1, ELEMENT e2) {
return e1.compareTo(e2);
}
})
}
}