Java Array Sum sum(int[] arr)

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

Description

sum

License

Open Source License

Declaration

public static long sum(int[] arr) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static long sum(Long[] longs) {
        long sum = 0;
        for (long i : longs) {
            sum += i;/* w ww  .j  av a  2s  . co  m*/
        }
        return sum;
    }

    public static long sum(int[] arr) {
        long sum = 0;
        for (int i : arr) {
            sum += i;
        }
        return sum;
    }

    public static double sum(double[] arr) {
        double sum = 0.0;
        for (double d : arr) {
            sum += d;
        }
        return sum;
    }

    public static double sum(Double[] arr) {
        double sum = 0.0;
        for (double d : arr) {
            sum += d;
        }
        return sum;
    }
}

Related

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