Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { public static double average(Collection<Double> arr) { if (arr.size() > 0) { return sum(arr) / arr.size(); } else { return 0; } } public static double sum(Collection<Double> arr) { double s = 0; for (Double a : arr) { s += a; } return s; } }