get Long List Average - Android java.util

Android examples for java.util:List Algorithm

Description

get Long List Average

Demo Code


//package com.java2s;
import java.util.Collection;

public class Main {

    public static Long getLongListAvg(Collection<Long> c) {
        return getLongListSum(c) / c.size();
    }/*from  w  w w. j  av  a 2s.c  o m*/

    public static Long getLongListSum(Collection<Long> c) {
        Long sum = 0l;
        for (Long i : c) {
            sum += i;
        }
        return sum;
    }
}

Related Tutorials