简体   繁体   English

绑定不匹配:MyClass1类型不是绑定参数的有效替代品 <T extends Comparator<T> &gt;类型的人 <T>

[英]Bound mismatch: The type MyClass1 is not a valid substitute for the bounded parameter <T extends Comparator<T>> of the type Person<T>

I get an error:::Bound mismatch: The type MyClass1 is not a valid substitute for the bounded parameter <T extends Comparator<T>> of the type Person<T> 我收到一个错误::: Bound不匹配:类型MyClass1不是有效的替代<T extends Comparator<T>> of the type Person<T>的有界参数<T extends Comparator<T>> of the type Person<T> Textended <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>>
{

}

The requirement is that MyClass1 needs to match T extends Comparator<T> . 要求是MyClass1需要匹配T extends Comparator<T>

For this to be the case, its declaration should be class MyClass1 extends Comparator<MyClass1> . 为此,其声明应为class MyClass1 extends Comparator<MyClass1>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 边界不匹配:类型A不是边界参数的有效替代品 <T extends Entity> 类型为TestService <T> - Bound mismatch: The type A is not a valid substitute for the bounded parameter <T extends Entity> of the type TestService<T> 为什么“类型绑定不匹配:类型? 扩展T不是有界参数的有效替代品 <E extends Enum<E> &gt;枚举类型 <E> “? - Why ”Type Bound mismatch: The type ? extends T is not a valid substitute for the bounded parameter <E extends Enum<E>> of the type Enum<E>“? 绑定不匹配:该类型不是绑定参数的有效替代 - Bound mismatch: The type is not a valid substitute for the bounded parameter 有界不匹配:类型不是有界参数的有效替代品<e extends comparable<e> &gt; 类型</e> - Bound mismatch: The type is not a valid substitute for the bounded parameter <E extends Comparable<E>> of the type 类型 T 不是有界参数的有效替代品 ` <t extends collection<?> &gt;</t> - Type T is not a valide Substitute for the bounded Parameter `<T extends Collection<?>> Java Generics - 绑定不匹配:类型 Object 不是绑定参数的有效替代品<e extends comparable<e> &gt;</e> - Java Generics - Bound mismatch: The type Object is not a valid substitute for the bounded parameter <E extends Comparable<E>> Java泛型:绑定不匹配:类型不是该类型的bounded参数的有效替代 - Java generics: Bound mismatch: The type is not a valid substitute for the bounded parameter of the type Java泛型,绑定不匹配:类型不是bounded参数的有效替代品 - Java generics , bound mismatch: The type is not a valid substitute for the bounded parameter Java泛型绑定不匹配:类型不是边界参数的有效替代品 - java generics Bound mismatch: The type is not a valid substitute for the bounded parameter 有界类型参数(T 扩展)和上限通配符(?扩展)之间的区别 - Difference between Bounded Type parameter (T extends) and Upper Bound Wildcard (? extends)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM