Java Array Average average(double[] values)

Here you can find the source of average(double[] values)

Description

average

License

Open Source License

Declaration

public static double average(double[] values) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

public class Main {
    public static double average(Collection<Double> values) {
        double ret = 0;
        for (Double val : values)
            ret += val;
        return ret / values.size();
    }//from   ww w  .  j  av  a2  s.c  o  m

    public static double average(double[] values) {
        double ret = 0;
        for (int i = 0; i < values.length; i++)
            ret += values[i];
        return ret / values.length;
    }
}

Related

  1. average(Double[] arr)
  2. average(double[] array)
  3. average(double[] array)
  4. average(double[] d)
  5. average(double[] values)
  6. average(double[] values)
  7. average(final double[] values)
  8. average(final Float... values)
  9. average(final float[] values)