【发布时间】:2018-10-01 04:05:11
【问题描述】:
我得到一个错误:::Bound mismatch: MyClass1 类型不是有界参数<T extends Comparator<T>> of the type Person<T> 的有效替代品
import java.util.Comparator;
public class Test
{
public static void main(String[] args)
{
Person<MyClass1> person2 = new Person<>(); // Bound mismatch: The type MyClass1 is not a valid substitute for the bounded parameter <T extends Comparator<T>> of the type Person<T>
}
}
class MyClass1<T extends Comparator<T>> implements Comparator<T>
{
@Override
public int compare(T o1, T o2)
{
return 0;
}
}
class Person<T extends Comparator<T>>
{
}
【问题讨论】: