Good evening. I am reviewing for an intro to Java exam and the instructor wrote a question I seem to be missing something.
Consider:
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?
The selection of answers I won't bother to list specifically as I don't require a specific answer to this. I need to understand what is supposed to happen. I plugged into an IDE and I get a gibberish answer if I add a System.out.print(mat);
"[[I@139a55"
While the instructor is expecting a selection of integers in either a 3x4 or 4x3 array. No integers exceed 3.
Any illumination on this would be invaluable to helping me understand the relationship between the for loops and the array to be done.