Here you can find the source of sum(Collection
public static double sum(Collection<Double> values)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static double sum(Collection<Double> values) { if (values == null || values.isEmpty()) { return 0L; }/* w w w. j ava 2 s.c o m*/ double sum = 0; for (Double value : values) { sum += value; } return sum; } }