Here you can find the source of sum(final Iterable
public static double sum(final Iterable<Double> values)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w .j av a 2 s.c om * Calculates the sum of an Array */ public static double sum(final double... array) { double sum = 0; for (final double element : array) { sum += element; } return sum; } /** * Calculates the sum of a Collection */ public static double sum(final Iterable<Double> values) { double sum = 0; for (final Double element : values) { sum += element; } return sum; } }