Java Array Average avg(double[] values)

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

Description

avg

License

Apache License

Declaration

public static double avg(double[] values) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static double avg(double[] values) {
        if (values.length > 0) {
            return sum(values) / values.length;
        } else {//from   ww  w. j a v a2  s .  co  m
            return 0.0;
        }
    }

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

Related

  1. avg(double... a)
  2. avg(double[] a)
  3. avg(double[] array)
  4. avg(double[] nums)
  5. avg(double[] values)
  6. avg(double[] x, int start, int end)
  7. avg(final double a, final double b)
  8. avg(final double... values)
  9. avg(float... numbers)