部分参考: http://blog.csdn.net/peakryuu/article/details/6180711
http://derpvail.iteye.com/blog/260992
不过两个出处都有些小bug,经过修正后如下:
public class StatisticalFunction {
public static double max(double[] p){
if (p.length == 0)
throw new IllegalArgumentException();
int len = p.length;
double max = p[0];
for (int i = 0; i < len; i++) {
if (max < p[i])
max = p[i];
}
return max;
}
(more…)