public static void print(Pair<? extends Fruit> p) { }
public static <T extends Fruit> void print(Pair<T> p) { }
这两句话效果应该是一样的吧? 那?作用有是什么呢? 什么情况下一定要用到呢?
public static <T extends Fruit> void print(Pair<T> p) { }
这两句话效果应该是一样的吧? 那?作用有是什么呢? 什么情况下一定要用到呢?
等效的
不过下面那个T可以在方法体中使用public static <T extends Fruit> void print(Pair<T> p) {
T a;
//操作a
}