Question: Consider the following code segment: int[][] mat = new int[3][4]; for (int row = 0; row < mat.length; row++) { for (int col = 0;
Consider the following code segment:
int[][] mat = new int[3][4];
for (int row = 0; row < mat.length; row++) {
for (int col = 0; col < mat[0].length; col++) {
if (row < col) {
mat[row][col] = 1;
}
else if (row == col) {
mat[row][col] = 2;
}
else {
mat[row][col] = 3;
}
}
}
What are the contents of mat after the code segment has been executed?
Step by Step Solution
3.45 Rating (152 Votes )
There are 3 Steps involved in it
Lets analyze the code segment step by step to determine the con... View full answer
Get step-by-step solutions from verified subject matter experts
