public class SumArray { public static void main(String[] args) { int[][] myGrid = { {1,2,3}, {4,5}, {6,7,8,9} }; int s; s = sum(myGrid); System.out.println( s ); } public static int sum(int[][] m) { int total = 0; for (int i = 0; i < m.length; i++) for (int j = 0; j < m[i].length; j++) total = total + m[i][j]; return total; } }