Here you can find the source of average(ArrayList
public static double average(ArrayList<Integer> array)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static double average(ArrayList<Integer> array) { Integer sum = 0;/*from w w w.ja v a2 s . c o m*/ if (!array.isEmpty()) { for (Integer mark : array) { sum += mark; } return sum.doubleValue() / array.size(); } return sum; } }