Java Collection Average average(Collection values)

Here you can find the source of average(Collection values)

Description

average

License

Open Source License

Declaration

public static <T extends Number> double average(Collection<T> values) 

Method Source Code

//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();
    }
}

Related

  1. average(Collection a)
  2. average(Collection col)
  3. average(Collection sizes)
  4. average(Collection values)
  5. average(Collection values)
  6. average(Collection values)