Here you can find the source of average(Collection
public static <T extends Number> double average(Collection<T> values)
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.util.Collection; public class Main { public static <T extends Number> double average(Collection<T> values) { double sum = 0; for (Number value : values) { sum += value.doubleValue();/*from w w w .ja va 2 s.c om*/ } return sum / values.size(); } }