java泛型中 的区别

时间:2022-09-27 15:55:43

(1)<? super String> is any class which is asuperclass of String (including String itself). (In this case, the only other suitable class isObject.)

即包括String的父类和它本身的类。

(2) <? extends String> (which in this specific case wouldn't be very useful asString is final, so it can have no subclasses).

即包括String的子类,而String没有子类,为null。