Android examples for java.lang:array
return the average value of the passed array
public class Main{ /**/* w w w. j av a 2 s. c o m*/ * return the average value of the passed array. */ public static double getAverage(double[] data) { int num = data.length; if (num == 0) { return 0; } double sum = data[0]; for (int i = 1; i < num; i++) { sum += data[i]; } return sum / num; } }