Here you can find the source of getAverage(List
Parameter | Description |
---|---|
values | the values. |
public static Double getAverage(List<Double> values)
//package com.java2s; import java.util.List; public class Main { /**//from ww w .j ava 2 s.c om * Returns the average of the given values. * * @param values the values. * @return the average. */ public static Double getAverage(List<Double> values) { Double sum = getSum(values); return sum / values.size(); } /** * Returns the sum of the given values. * * @param values the values. * @return the sum. */ public static Double getSum(List<Double> values) { Double sum = 0.0; for (Double value : values) { if (value != null) { sum += value; } } return sum; } }