Java Array Sum sum(int[] array)

Here you can find the source of sum(int[] array)

Description

Returns the sum of all elements of the given array.

License

Open Source License

Parameter

Parameter Description
array a parameter

Declaration

public static int sum(int[] array) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w  ww.  jav a 2s  .com*/
     * Returns the sum of all elements of the given array.
     * 
     * @param array
     * @return
     */
    public static int sum(int[] array) {
        int sum = 0;
        for (int i : array) {
            sum += i;
        }
        return sum;
    }
}

Related

  1. sum(int[] arr)
  2. sum(int[] arr)
  3. sum(int[] arr)
  4. sum(int[] arr)
  5. sum(int[] array)
  6. sum(int[] array)
  7. sum(int[] array)
  8. sum(int[] array)
  9. sum(int[] intArray)