Here you can find the source of sum(ArrayList
public static double sum(ArrayList<Double> values)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; public class Main { public static double sum(ArrayList<Double> values) { double sum = 0; for (double value : values) { sum += value;//from www . j av a 2 s . c om } return sum; } public static double sum(double[] values) { double sum = 0; for (double value : values) { sum += value; } return sum; } public static int sum(int[] values) { int sum = 0; for (int value : values) { sum += value; } return sum; } }