Here you can find the source of mean(List
Parameter | Description |
---|---|
numbers | the numbers to calculate the mean. |
public static double mean(List<Number> numbers)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /**/*w w w .j av a 2 s. c o m*/ * Returns the mean number in the numbers list. * * @param numbers the numbers to calculate the mean. * @return the mean of the numbers. */ public static double mean(List<Number> numbers) { double sum = sum(numbers); return sum / numbers.size(); } /** * Returns the sum number in the numbers list. * * @param numbers the numbers to calculate the sum. * @return the sum of the numbers. */ public static double sum(List<Number> numbers) { double sum = 0; for (Number value : numbers) { sum += value.doubleValue(); } return sum; } }