Here you can find the source of getSum(int[] array)
public static int getSum(int[] array)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static double getSum(Collection<? extends Number> values) { double sm = 0; for (Number value : values) { sm += value.doubleValue();//from w w w . j a v a 2s .c o m } return sm; } public static int getSum(int[] array) { // return sum of all elements in array int sum = 0; for (int val : array) sum += val; return sum; } public static float getSum(float[] array) { // return sum of all elements in array float sum = 0; for (float val : array) sum += val; return sum; } public static double getSum(double[] array) { // return sum of all elements in array double sum = 0; for (double val : array) sum += val; return sum; } public static Integer getSum(Integer[] array) { Integer sm = 0; for (Integer value : array) sm += value; return sm; } public static float getSum(float[][][] array) { // return array of three-dimensional double array float sm = 0; for (float[][] anArray : array) { for (int i = 0; i < array[0][0].length; i++) { for (int j = 0; j < array[0].length; j++) sm += anArray[i][j]; } } return sm; } }