Here you can find the source of sum(ArrayList
public static <T extends Number> double sum(ArrayList<T> a)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static <T extends Number> double sum(ArrayList<T> a) { double sum = 0; for (int i = 0; i < a.size(); i++) sum += a.get(i).doubleValue(); return sum; }// w w w.j av a 2 s .co m }