Here you can find the source of average(ArrayList
public static double average(ArrayList<Double> nums)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static double average(double nums[]) { double avg = 0.0; for (int i = 0; i < nums.length; i++) { avg += nums[i];// w w w . j av a 2 s . c o m } return avg / (double) nums.length; } public static double average(ArrayList<Double> nums) { double avg = 0.0; for (int i = 0; i < nums.size(); i++) { avg += nums.get(i); } return avg / (double) nums.size(); } }