<T extends Comparable<? super T>>什么意思

<T extends Comparable<? super T>>
首先这是运用了java的泛型
①extends后面跟的类型如<任意字符 extends 类/接口>表示泛型的上限

import java.util.*; 

class Demo<T extends AbstractList>{}

 public class Test { 
    public static void main(String[] args) { 
        Demo<ArrayList> p = null; // 编译正确 
    //这里因为ArrayList是AbstractList的子类所以通过 
    //如果改为Demo<AbstractCollection> p = null;就会报错这样就限制了上限 } } 
②同样的super表示泛型的下限
③<T extends Comparable<? super T>>这里来分析T表示任意字符名,extends对泛型上限进行了限制即T必须是Comparable<? super T>的子类,然后<? super T>表示Comparable<>中的类型下限为T

Java泛型命名

E - Element (used extensively by the Java Collections Framework)
K - Key
N - Number
T - Type
V - Value
S,U,V etc. - 2nd, 3rd, 4th types

https://www.zhihu.com/question/25548135

原文地址:https://www.cnblogs.com/twoheads/p/9627223.html