Here you can find the source of sum(List
public static <T extends Number> double sum(List<T> listOfNumbers)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static <T extends Number> double sum(List<T> listOfNumbers) { double sum = 0; for (T number : listOfNumbers) { sum += number.doubleValue(); }/*from w w w . java2 s .co m*/ return sum; } }