Java List Sum calculateSum(List valueList)

Here you can find the source of calculateSum(List valueList)

Description

Calculates the sum of the values of a given list.

License

Open Source License

Parameter

Parameter Description
valueList a parameter

Return

sum

Declaration

public static double calculateSum(List<Double> valueList) 

Method Source Code

//package com.java2s;
/* *********************************************************************** *
 * project: org.matsim.*                                       *
 *                                                                         *
 * *********************************************************************** *
 *                                                                         *
 * copyright       : (C) 2008 by the members listed in the COPYING,        *
 *                   LICENSE and WARRANTY file.                            *
 * email           : info at matsim dot org                                *
 *                                                                         *
 * *********************************************************************** *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *   See also COPYING, LICENSE and WARRANTY file                           *
 *                                                                         *
 * *********************************************************************** */

import java.util.List;

public class Main {
    /**//from  ww  w .j ava  2  s  . co m
     * Calculates the sum of the values of a given list.
     * 
     * @param valueList
     * @return sum
     */
    public static double calculateSum(List<Double> valueList) {
        double sum = 0.;
        for (double i : valueList) {
            sum = sum + i;
        }
        return sum;
    }
}

Related

  1. addByteToMessage(final List message, final byte bytevalue, final int checksum)
  2. adjustSumOfSquareValue(List oper, Number adjustedOper1)
  3. checkSum(List stringList)
  4. getListSum(List list)
  5. getResidualSumOfSquares(List response, List samples, int ta)
  6. getSum(final List values)