Java List Mean mean(List list)

Here you can find the source of mean(List list)

Description

mean

License

Open Source License

Declaration

public static double mean(List<Double> list) 

Method Source Code

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

import java.util.List;

public class Main {
    public static double mean(List<Double> list) {
        if (list == null || list.size() == 0) {
            return 0;
        } else {//from  w  w  w.  java 2s. c  om
            double sum = 0;
            int num = 0;
            for (Double d : list) {
                if (d != null) {
                    sum += d;
                    num++;
                }
            }
            return sum / num;
        }
    }
}

Related

  1. mean(final List list)
  2. mean(List data)
  3. mean(List nums, int start, int size)
  4. mean(List data)
  5. mean(List list)
  6. mean(List vals)
  7. mean(List values)
  8. mean(List values)
  9. mean(List values)