获取长列表的平均值
/** nowjava.com - 时代Java **/ //package com.nowjava; import java.util.List; public class Main { public static float getAverage(List<Long> allTimes) { long total = getTotal(allTimes); return total / (float) allTimes.size(); } public static long getTotal(List<Long> times) { long total = 0; for (Long time : times) { total = total + time; } return total; } }