-1

What is the difference between these 2 methods which work similar. Can any one explain me the exact difference?

**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;
}
zx485
  • 28,498
  • 28
  • 50
  • 59

1 Answers1

0

There is no difference. They will work exactly the same on exactly the same inputs.

Louis Wasserman
  • 191,574
  • 25
  • 345
  • 413