public class MyClass {
public static void main(String args[]) {
int[][] matrix = {{31, 22, 33},
{42, 85, 987}};
print_array(matrix);
}
public static void print_array(int[][] matrix) {
int rows = matrix.length;
int cols = matrix[0].length;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++)
System.out.format("%4d", matrix[i][j]);
System.out.println();
}
}
}
/*
run:
31 22 33
42 85 987
*/