Here you can find the source of sum(Collection
Parameter | Description |
---|---|
values | a parameter |
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(double[] values) { double sum = 0.0; for (int i = 0; i < values.length; i++) { sum += values[i];/*from w w w .j a va 2 s . c o m*/ } return sum; } /** * Calculate sum * @param values * @return */ public static double sum(Collection<Double> values) { double sum = 0.0; for (Double value : values) { sum += value; } return sum; } }