//2D array as argument to method, length public class eg10_2DArray { public static void main(String[] args) { int[][] numbers = { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12} }; //Display contents of array System.out.println("Here are the values in the array."); showArray(numbers); System.out.println("The sum of the values is " + arraySum(numbers)); } private static void showArray(int[][] array) { for (int row=0; row < array.length; row++) { //System.out.print(row + " "); for (int col=0; col < array[row].length; col++) { //System.out.print(row + "," + col+ "; "); System.out.print(array[row][col] + " "); } System.out.println(); } } private static int arraySum(int[][] array) { int total = 0; for (int row=0; row < array.length; row++) { for (int col=0; col < array[row].length; col++) { total = total + array[row][col]; } } return total; } }