-2
這兩種方法有什麼區別,其工作原理相似。任何人都可以解釋我的確切區別嗎?這兩種方法有什麼區別
**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;
}