Java Array Average average(int... is)

Here you can find the source of average(int... is)

Description

average

License

Apache License

Declaration

public static int average(int... is) 

Method Source Code

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

public class Main {
    public static int average(int... is) {
        if (is.length == 0)
            return 0;
        int i = 0;
        for (double ii : is) {
            i += ii;/*from   w ww  .  j a v  a 2  s. c om*/
        }
        return i / is.length;
    }

    public static float average(float... fs) {
        if (fs.length == 0)
            return 0;
        float f = 0;
        for (double ff : fs) {
            f += ff;
        }
        return f / fs.length;
    }

    public static double average(double... ds) {
        if (ds.length == 0)
            return 0;
        double d = 0;
        for (double dd : ds) {
            d += dd;
        }
        return d / ds.length;
    }
}

Related

  1. average(final int totalAmount, final int orderCount)
  2. average(final T p_num1, final T p_num2)
  3. average(float[][] data, int startIndex, int endIndex)
  4. average(float[][] originalValues, float[][] newValues, int[] indexArray)
  5. average(int argb0, int argb1)
  6. average(int... values)
  7. average(int[] a)
  8. average(int[] array)
  9. average(int[] pixels)