Java ArrayList Average average(ArrayList array)

Here you can find the source of average(ArrayList array)

Description

average

License

Open Source License

Declaration

public static double average(ArrayList<Integer> array) 

Method Source Code


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

import java.util.ArrayList;

public class Main {
    public static double average(ArrayList<Integer> array) {
        Integer sum = 0;/*from w w  w.ja v  a2 s  . c  o  m*/
        if (!array.isEmpty()) {
            for (Integer mark : array) {
                sum += mark;
            }
            return sum.doubleValue() / array.size();
        }
        return sum;

    }
}

Related

  1. average(ArrayList nums)
  2. averageInColumns(ArrayList lines)
  3. getAverage(ArrayList data)
  4. getAverage(ArrayList values)
  5. getAverageOfList(ArrayList values)