Here you can find the source of sumArray(int[] arr)
public static int sumArray(int[] arr)
//package com.java2s; public class Main { /** Returns the sum of all values in an array. Args: Array */ public static int sumArray(int[] arr) { int sum = 0; for (int i = 0; i < arr.length; i++) { sum += arr[i];/* w w w. j a va 2 s .c o m*/ } return sum; } /** Returns the sum of all values in an array. Args: Array */ public static double sumArray(double[] arr) { double sum = 0; for (int i = 0; i < arr.length; i++) { sum += arr[i]; } return sum; } /** Returns the sum of all values in an array. Args: Array */ public static float sumArray(float[] arr) { float sum = 0; for (int i = 0; i < arr.length; i++) { sum += arr[i]; } return sum; } public static long sumArray(long[] arr) { long sum = 0; for (int i = 0; i < arr.length; i++) { sum += arr[i]; } return sum; } }