Java Array Average average(Double[] arr)

Here you can find the source of average(Double[] arr)

Description

average

License

Open Source License

Declaration

public static Double average(Double[] arr) 

Method Source Code

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

public class Main {
    public static Double average(Double[] arr) {
        return sum(arr) / arr.length;
    }// w  w  w  .ja va 2s .c  om

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

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

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

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

Related

  1. average(double x1, double x2)
  2. average(double... args)
  3. average(double... vals)
  4. average(double[] a)
  5. average(double[] a)
  6. average(double[] array)
  7. average(double[] array)
  8. average(double[] d)
  9. average(double[] values)