Here you can find the source of average(int[] array)
public static double average(int[] array)
//package com.java2s; //License from project: Open Source License public class Main { public static double average(int[] array) { return sum(array) / array.length; }//from w ww . j a v a 2s.c o m public static double average(int[][] matrix) { return sum(matrix) / (matrix.length * matrix[0].length); } public static int sum(int[] array) { int sum = 0; for (int i = 0; i < array.length; i++) { sum += array[i]; } return sum; } public static int sum(int[][] array) { int sum = 0; for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[i].length; j++) { sum += array[i][j]; } } return sum; } }