The given code defines an ArrayList< Integer > and fills it with few values:
ArrayList<Integer> list = new ArrayList<>();
// fill the list
list.add(100);
list.add(200);
We have defined a method that returns sum of all values of a given collection. The collection parameter c has to be generic to accept any kind of Collection of Number objects. You have to tell what is the correct parameter type of method add from given choices.
double add( ______ c ) {
double sum = 0;
for(Number num : c)
sum += num.doubleValue();
return sum;
}
When add is called on list, it returns 300.0:
System.out.println(add(list)); // 300.0
Which one of the following choices can replace ______
above?