Java ArrayList Sum Sum(ArrayList values)

Here you can find the source of Sum(ArrayList values)

Description

Calculates the sum of a list of numeric values.

License

Open Source License

Parameter

Parameter Description
values List of numeric values

Return

Summed value

Declaration

public static double Sum(ArrayList<Double> values) 

Method Source Code


//package com.java2s;
// it under the terms of the GNU General Public License as published by

import java.util.*;

public class Main {
    /** Calculates the sum of a list of numeric values.
     */*w w  w  .  j  av a  2  s  .c  o  m*/
     * @param values List of numeric values
     * @return Summed value
     */
    public static double Sum(ArrayList<Double> values) {
        double sum = 0.0;

        for (double value : values)
            sum += value;

        return sum;
    }
}

Related

  1. sum(ArrayList values)
  2. sum(ArrayList values)
  3. sum(ArrayList a)
  4. sumInColumns(ArrayList lines)