Java Array Sum sum(Integer[] array)

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

Description

sum

License

Open Source License

Declaration

public static int sum(Integer[] array) 

Method Source Code


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

import java.util.ArrayList;

public class Main {
    public static int sum(Integer[] array) {
        int x = 0;
        for (int i = 0; i < array.length; i++) {
            x += array[i];//from w w w. j  a v  a2s  .co  m
        }
        return x;
    }

    public static int sum(ArrayList<Integer> list) {
        int x = 0;
        for (int i = 0; i < list.size(); i++) {
            x += list.get(i);
        }
        return x;
    }
}

Related

  1. sum(int[] values)
  2. sum(int[] values, int begin, int end)
  3. sum(int[] values, int startIndex, int stopIndex)
  4. sum(Integer... integers)
  5. sum(Integer... ints)
  6. sum(long array[])
  7. sum(long... values)
  8. sum(long[] array)
  9. sum(long[] array)