get Int List Average - Android java.util

Android examples for java.util:List Algorithm

Description

get Int List Average

Demo Code


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

public class Main {

    public static int getIntListAvg(Collection<Integer> c) {
        return getIntListSum(c) / c.size();
    }/*from  w ww  .  jav  a 2  s.co  m*/

    public static int getIntListSum(Collection<Integer> c) {
        int sum = 0;
        for (Integer i : c) {
            sum += i;
        }
        return sum;
    }
}

Related Tutorials