List of utility methods to do Array Sum
long | sum(long[] array) sum if (array == null) { return 0L; long sum = 0; for (int i = 0; i < array.length; i++) { sum += array[i]; return sum; ... |
long | sum(long[] counts) sum long sum = 0; for (int i = 0; i < counts.length; i++) { sum += counts[i]; return sum; |
double | sum(Number... numbers) to overcome Exception occur when Integer, Double or other Number object is null when try to do mathematics operation (+-/*). double total = 0; for (Number number : numbers) { total += toDouble(number); return total; |
double | sum(Number[] array) Returns sum of all the elements in the array. double result; int i; result = 0.0; for (i = 0; i < array.length; i++) result += array[i].doubleValue(); return result; |
Number | sum(Number[] numbers) Sums an array of numbers together while using the correct class type. Number newSum = (Number) getObject(numbers); if (newSum == null) { return null; if (newSum instanceof Integer) { int sum = 0; int nextValue; for (int i = 0; i < numbers.length; i++) { ... |
Object[] | sum(Object[] srcOne, Object[] srcTwo) sum Object[] result = new Object[srcOne.length + srcTwo.length]; System.arraycopy(srcOne, 0, result, 0, srcOne.length); System.arraycopy(srcTwo, 0, result, srcOne.length, srcTwo.length); return result; |
int | sum(short tab[], int a, int b) sum int sum = 0; for (int i = a; i <= b; i++) { sum += tab[i]; return sum; |
int | sum(short[] ary) Sum of an array return sum(ary, 0, ary.length);
|
String | sum(String[] tokens, int start, int length, String separator) sum StringBuffer buffer = new StringBuffer(); for (int i = start; i < length + start; i++) { buffer.append(tokens[i]); if (i != length + start - 1) { buffer.append(separator); return buffer.toString(); ... |
double[] | sum3(double[] a, double[] b) get the sum of two 3-dimension vector return new double[] { a[0] + b[0], a[1] + b[1], a[2] + b[2] }; |