Java List Sum sum(List numbers)

Here you can find the source of sum(List numbers)

Description

Returns the sum number in the numbers list.

License

Open Source License

Parameter

Parameter Description
numbers the numbers to calculate the sum.

Return

the sum of the numbers.

Declaration

public static double sum(List<Number> numbers) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    /**/* w  w w  . j  a v  a 2  s  . c o m*/
     * Returns the sum number in the numbers list.
     *
     * @param numbers the numbers to calculate the sum.
     * @return the sum of the numbers.
     */
    public static double sum(List<Number> numbers) {
        double sum = 0;
        for (Number value : numbers) {
            sum += value.doubleValue();
        }
        return sum;
    }
}

Related

  1. sum(List vals)
  2. sum(List l)
  3. sum(List list)
  4. sum(List lst)
  5. sum(List numbers)
  6. sum(List listOfNumbers)
  7. sum_ints(List list)
  8. sumAll(List list)
  9. sumAllColumnsOfMatrix(List> matrix)