大神求解java List的一个问题!!谢谢
下面B是A的子类
List<? extends A> result =new ArrayList<B>();
然后调用方法method(result,result);为什么还会报错???
但调用method(result);和method3(result,result)不会报错,是因为参数只能是一个<T>类型的吗?
public <T> boolean method(List<T> list,List<T> list2)throws Exception {
........................
}
public <T> boolean method2(List<T> list)throws Exception {
........................
}
public <T> boolean method3(List<T> list,List<?> list2)throws Exception {
........................
}