Page 365 - AP Computer Science A, 7th edition
P. 365

NOTE
The use of the nested for-each loop is OK. Modifying the objects in the matrix with a mutator method is fine. What you can’t do is replace the Card objects with new Cards.
Example 4
The major and minor diagonals of a square matrix are shown below :
You can process the diagonals as follows:
 int[][] mat = new int[SIZE][SIZE];
for (int i = 0; i < SIZE; i++)
Process mat[i][i]; OR
Process mat[i][SIZE – i – 1];
//SIZE is a constant int value
//major diagonal //minor diagonal
Two-Dimensional Array as Parameter
Example 1






















































































   363   364   365   366   367