Java Array Average avg(double[] nums)

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

Description

avg

License

Apache License

Declaration

public static double avg(double[] nums) 

Method Source Code

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

public class Main {
    public static double avg(double[] nums) {
        double sum = 0;
        for (double n : nums)
            sum += n;//from   w  ww. ja v a2s .  com
        return sum / nums.length;
    }

    public static double avg(long[] nums) {
        long sum = 0;
        for (long n : nums)
            sum += n;
        return sum / nums.length;
    }
}

Related

  1. avg(double v1, double v2)
  2. avg(double values[], int size, boolean ignoreNan)
  3. avg(double... a)
  4. avg(double[] a)
  5. avg(double[] array)
  6. avg(double[] values)
  7. avg(double[] values)
  8. avg(double[] x, int start, int end)
  9. avg(final double a, final double b)