Here you can find the source of sum(Iterable
Parameter | Description |
---|---|
as | an iterable of double values |
public static double sum(Iterable<Double> as)
//package com.java2s; public class Main { /**//from ww w . j a v a2 s .c o m * The sum of a sequence of floating-point numbers * * @param as an iterable of double values * @return the sum of the double values */ public static double sum(Iterable<Double> as) { double sum = 0; for (double a : as) { sum += a; } return sum; } /** * The sum of an array of floating-point numbers * * @param as an array of double values * @return the sum of the double values */ public static double sum(double[] as) { double sum = 0; for (double a : as) { sum += a; } return sum; } }