Java Utililty Methods Array Sum

List of utility methods to do Array Sum

Description

The list of methods to do Array Sum are organized into topic(s).

Method

longsum(int[] values)
Returns the sum of all int values.
throw new UnsupportedOperationException();
intsum(int[] values)
Computes the sum of the values
int sum = 0;
for (int value : values) {
    sum += value;
return sum;
intsum(int[] values, int begin, int end)
sum
int s = 0;
for (int i = begin; i < end; i++) {
    s += values[i];
return s;
intsum(int[] values, int startIndex, int stopIndex)
sum
int sum = 0;
for (int i = startIndex; i <= stopIndex; i++) {
    int value = values[i];
    sum += value;
return sum;
intsum(Integer... integers)
build the sum of given Integers regardless of null {Category} NumberUtil {talendTypes} int | Integer {param} int(2,5,99,120) integers: integers to sum.
int sum = 0;
for (Integer i : integers) {
    if (i != null) {
        sum = sum + i.intValue();
return sum;
Integersum(Integer... ints)
sum
Integer res = null;
for (Integer i : ints) {
    if (null != i) {
        if (res == null) {
            res = i;
        } else {
            res = res + i;
return res;
intsum(Integer[] array)
sum
int x = 0;
for (int i = 0; i < array.length; i++) {
    x += array[i];
return x;
longsum(long array[])
Sum of the values in the array
int size = array.length;
long sum = 0;
for (int i = 0; i < size; i++) {
    sum += array[i];
return sum;
longsum(long... values)
Compute the sum of the given array
long total = 0;
for (long v : values)
    total += v;
return (total);
doublesum(long[] array)
Returns the sum of all elements in the array.
double out = 0;
for (int i = 0; i < array.length; i++) {
    out += array[i];
return out;