Here you can find the source of sum(int[] a)
public static int sum(int[] a)
//package com.java2s; //License from project: Open Source License public class Main { public static int sum(int[] a) { int s = 0; for (int x : a) s += x;//from w ww.ja v a 2s.c om return s; } public static int sum(int[][] a) { int s = 0; for (int[] x : a) s += sum(x); return s; } public static int sum(int[][][] a) { int s = 0; for (int[][] x : a) s += sum(x); return s; } }