Java ArrayList Sum sum(ArrayList values)

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

Description

sum

License

Apache License

Declaration

public static double sum(ArrayList<Double> values) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

public class Main {
    public static double sum(ArrayList<Double> values) {
        double sum = 0;
        for (double value : values) {
            sum += value;//from   www . j av a  2  s  . c om
        }
        return sum;
    }

    public static double sum(double[] values) {
        double sum = 0;
        for (double value : values) {
            sum += value;
        }
        return sum;
    }

    public static int sum(int[] values) {
        int sum = 0;
        for (int value : values) {
            sum += value;
        }
        return sum;
    }
}

Related

  1. sum(ArrayList values)
  2. Sum(ArrayList values)
  3. sum(ArrayList a)
  4. sumInColumns(ArrayList lines)
  5. sumVector(ArrayList v1, ArrayList v2)