Lecture Notes on 12 Oct 2011 // Traversing all the elements of a 2-D array for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { ... } } // Reversing the rows of a 2-D array public static int[][] reverseRows (int[][] a) { int[][] b = new int [a.length][a[0].length]; for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { b[i][j] = a[i][a.length -1 - j]; } } return b; }