Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.List;

public class Main {
    public static Double listAvg(List<Double> list) {
        if (list == null || list.isEmpty()) {
            return null;
        }

        Double listSum = listSum(list);

        return listSum / list.size();
    }

    public static Double listSum(List<Double> list) {
        if (list == null || list.isEmpty()) {
            return null;
        }

        Double sum = 0.0;

        for (Double value : list) {
            sum += value;
        }

        return sum;
    }
}