Java ArrayList Average average(ArrayList nums)

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

Description

average

License

Open Source License

Declaration

public static double average(ArrayList<Double> nums) 

Method Source Code


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

import java.util.ArrayList;

public class Main {
    public static double average(double nums[]) {
        double avg = 0.0;
        for (int i = 0; i < nums.length; i++) {
            avg += nums[i];// w w  w  . j av  a 2  s  .  c o m
        }
        return avg / (double) nums.length;
    }

    public static double average(ArrayList<Double> nums) {
        double avg = 0.0;
        for (int i = 0; i < nums.size(); i++) {
            avg += nums.get(i);
        }
        return avg / (double) nums.size();
    }
}

Related

  1. average(ArrayList array)
  2. averageInColumns(ArrayList lines)
  3. getAverage(ArrayList data)
  4. getAverage(ArrayList values)