Here you can find the source of mean(List
public static double mean(List<Double> list)
//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; } } }