Java Array Sum sum(final Double[] doubles)

Here you can find the source of sum(final Double[] doubles)

Description

Get the sum of an array of doubles.

License

Apache License

Parameter

Parameter Description
doubles the array to sum.

Return

the sum of the array

Declaration

public static Double sum(final Double[] doubles) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from  ww w  .j a  v  a2  s .  c o  m
     * Get the sum of an array of doubles.
     * @param doubles the array to sum.
     * @return the sum of the array
     */
    public static Double sum(final Double[] doubles) {
        Double sum = 0.0;
        for (int j = 0; j < doubles.length; j++) {
            sum += doubles[j];
        }
        return sum;
    }

    /**
     * Get the sum of an array of integers.
     * @param integers the array to sum.
     * @return the sum of the array
     */
    public static Integer sum(final Integer[] integers) {
        Integer sum = 0;
        for (int j = 0; j < integers.length; j++) {
            sum += integers[j];
        }
        return sum;
    }
}

Related

  1. sum(final double... values)
  2. sum(final double[] a)
  3. sum(final double[] arr)
  4. sum(final double[] array)
  5. sum(final double[] decay, final int factor)
  6. sum(final double[] productMix)
  7. sum(final double[] target)
  8. sum(final double[] vec)
  9. sum(final float[] x)