Java List Average average(List arr)

Here you can find the source of average(List arr)

Description

average

License

Open Source License

Declaration

public static double average(List<Double> arr) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    public static double average(List<Double> arr) {
        double sum = 0.0d;
        int count = 0;
        for (int i = 0; i < arr.size(); i++) {
            if (!Double.isNaN(arr.get(i))) {
                sum += arr.get(i);/*from   w w  w.  j a va 2s  .c  om*/
                count++;
            }
        }
        return sum / ((double) count);
    }
}

Related

  1. addAverage(List list, int InColumn1, int InColumn2, int resultColumn)
  2. average(final List vals, final int maxI)
  3. average(List collected)
  4. average(List list)
  5. average(List numbers)
  6. average(List observations)
  7. average(List collection)