Java examples for java.util:Collection Algorithm
avg value from Collection of numbers
//package com.java2s; import java.util.Collection; public class Main { public static Float avg(Collection<Number> list) { Number sum = 0;/*ww w .j av a2 s. c o m*/ for (Number item : list) { sum = sum.floatValue() + item.floatValue(); } return sum.floatValue() / list.size(); } }