Android Array Average average(int[] pixels)

Here you can find the source of average(int[] pixels)

Description

average

Declaration

public static int average(int[] pixels) 

Method Source Code

//package com.java2s;

public class Main {

    public static int average(int[] pixels) {
        float m = 0;
        for (int i = 0; i < pixels.length; ++i) {
            m += pixels[i];/*from  w  w  w.  java2 s  . co m*/
        }
        m = m / pixels.length;
        return (int) m;
    }

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

Related

  1. getArrayAvg(int... i)
  2. average(double[] pixels)