Here you can find the source of average(Collection
public static double average(Collection<Double> sizes)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static double average(Collection<Double> sizes) { double sum = 0.0; int count = sizes.size(); for (double size : sizes) { sum += size;// ww w . j a va2s.com } return count > 0 ? sum / count : 0.0; } }