Java Collection Sum sum(Collection values)

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

Description

sum

License

Open Source License

Declaration

public static double sum(Collection<Double> values) 

Method Source Code


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

import java.util.Collection;

public class Main {
    public static double sum(Collection<Double> values) {
        if (values == null || values.isEmpty()) {
            return 0L;
        }/*  w  w  w.  j ava 2  s.c o  m*/

        double sum = 0;
        for (Double value : values) {
            sum += value;
        }
        return sum;
    }
}

Related

  1. sum(Collection numbers)
  2. sum(Collection collection)
  3. sum(Collection list)
  4. sum(Collection values)
  5. sum(Collection values)
  6. sum(Collection values)
  7. sum(Collection vec)