Java List Sum sum(final List list)

Here you can find the source of sum(final List list)

Description

Sums a list of numbers.

License

GNU General Public License

Parameter

Parameter Description
list the list

Return

the double

Declaration

public static double sum(final List<? extends Number> list) 

Method Source Code

//package com.java2s;
/*//from   w w  w . j  a  v a2s .c  om
 * Title:        CloudSim Toolkit
 * Description:  CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
 * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html
 *
 * Copyright (c) 2009-2012, The University of Melbourne, Australia
 */

import java.util.List;

public class Main {
    /**
     * Sums a list of numbers.
     * 
     * @param list the list
     * @return the double
     */
    public static double sum(final List<? extends Number> list) {
        double sum = 0;
        for (Number number : list) {
            sum += number.doubleValue();
        }
        return sum;
    }
}

Related

  1. getSum(List longList)
  2. getSumOfInts(List ints)
  3. getSumOfPositiveDoubles(List scores)
  4. removeOne(List summary, int start)
  5. sum(final List list1, final List list2)
  6. sum(final List list)
  7. sum(int[] list)
  8. sum(List list)
  9. sum(List a)