Java List Average average(List list)

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

Description

average

License

Open Source License

Declaration

public static double average(List<Double> list) 

Method Source Code

//package com.java2s;
//License from project: GNU General Public License 

import java.util.List;

public class Main {
    public static double average(List<Double> list) {
        return sum(list) / list.size();
    }//from   w  w w  .  j  av  a2s . c  om

    public static double sum(List<Double> list) {
        double sum = 0.0;
        for (double v : list) {
            sum += v;
        }
        return sum;
    }

    public static double sum(double[][] a) {
        double sum = 0.0;
        for (int i = 0; i < a.length; i++) {
            sum += sum(a[i]);
        }
        return sum;
    }

    public static double sum(double[] a) {
        double sum = 0.0;
        for (int i = 0; i < a.length; i++) {
            sum += a[i];
        }
        return sum;
    }

    public static int sum(int[] a) {
        int sum = 0;
        for (int i = 0; i < a.length; i++) {
            sum += a[i];
        }
        return sum;
    }
}

Related

  1. addAverage(List list, int InColumn1, int InColumn2, int resultColumn)
  2. average(final List vals, final int maxI)
  3. average(List collected)
  4. average(List arr)
  5. average(List numbers)
  6. average(List observations)
  7. average(List collection)
  8. averageDouble(final List values)