【发布时间】:2017-08-18 01:00:25
【问题描述】:
这两种工作方式相似的方法有什么区别。谁能解释一下具体的区别?
**Accepts the list with all Number Type**
public static double sum(List<? extends Number> list)
{
double sum = 0;
for(Number n : list){
sum += n.doubleValue();
}
return sum;
}
// Accepts the list with all Number Type
public static <T extends Number> double sum1(List<T> list){
double sum = 0;
for(T n : list){
sum += n.doubleValue();
}
return sum;
}
【问题讨论】: