array Average - Android java.lang

Android examples for java.lang:array calculation

Description

array Average

Demo Code


import java.util.Random;
import android.util.FloatMath;

public class Main{
    public static final float arrayAverage(final float[] pValues) {
        return MathUtils.arraySum(pValues) / pValues.length;
    }/*from   w  ww  . ja  v a  2  s  . co m*/
    public static final float arraySum(final float[] pValues) {
        float sum = 0;
        final int valueCount = pValues.length;
        for (int i = 0; i < valueCount; i++) {
            sum += pValues[i];
        }
        return sum;
    }
}

Related Tutorials