Here you can find the source of sum(double[] d)
public static double sum(double[] d)
//package com.java2s; //License from project: Open Source License public class Main { public static double sum(double[] d) { double ret = 0; for (int i = 0; i < d.length; i++) { ret += d[i];// w w w. j av a 2 s . com } return ret; } public static double sum(double[][] d) { double ret = 0; for (int i = 0; i < d.length; i++) { for (int j = 0; j < d[0].length; j++) { ret += d[i][j]; } } return ret; } public static double sum(double[] d, int n) { double ret = 0; for (int i = 0; i < n; i++) { ret += d[i]; } return ret; } public static int sum(int[] d) { int ret = 0; for (int i = 0; i < d.length; i++) { ret += d[i]; } return ret; } public static float sum(float[] d) { float ret = 0; for (int i = 0; i < d.length; i++) { ret += d[i]; } return ret; } public static long sum(long[] d) { long ret = 0; for (int i = 0; i < d.length; i++) { ret += d[i]; } return ret; } }