Here you can find the source of average(double[] a)
Parameter | Description |
---|---|
a | The array to calculate the average for. |
public static double average(double[] a)
//package com.java2s; //License from project: Open Source License public class Main { /**//from www.j a va 2 s. com * @param a The array to calculate the average for. * @return The average over all elements in the array. */ public static double average(double[] a) { return sum(a) / a.length; } /** * @param a The array to sum. * @return The sum over all elements in the array. */ public static double sum(double[] a) { double sum = 0; for (int i = 0; i < a.length; i++) sum += a[i]; return sum; } /** * @param a The array to sum. * @return The sum over all elements in the array. */ public static long sum(int[] a) { long sum = 0; for (int i = 0; i < a.length; i++) sum += a[i]; return sum; } }