Java Array Sum sum(int[] values, int begin, int end)

Here you can find the source of sum(int[] values, int begin, int end)

Description

sum

License

Open Source License

Declaration

public static int sum(int[] values, int begin, int end) 

Method Source Code

//package com.java2s;

public class Main {
    public static int sum(int[] values, int begin, int end) {
        int s = 0;
        for (int i = begin; i < end; i++) {
            s += values[i];/*from www  . jav  a 2 s .  c  o  m*/
        }
        return s;
    }

    public static int sum(int[] values) {
        return sum(values, 0, values.length);
    }

    public static int sum(int[][] values) {
        int s = 0;
        for (int i = 0; i < values.length; i++) {
            for (int j = 0; j < values[i].length; j++) {
                s += values[i][j];
            }
        }
        return s;
    }
}

Related

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