public class PrintSpecificRowOfMatrix_Java {
public static void PrintSpecificRowOfMatrix(int[][] matrix, int row) {
int cols = matrix[0].length;
for (int j = 0; j < cols; j++) {
System.out.print(matrix[row][j] + " ");
}
}
public static void main(String[] args) {
int[][] matrix = {
{ 4, 7, 9, 18, 29, 0 },
{ 1, 9, 18, 99, 4, 3 },
{ 9, 17, 89, 2, 7, 5 },
{ 19, 49, 6, 1, 9, 8 },
{ 29, 4, 7, 9, 18, 6 } };
int row = 2;
PrintSpecificRowOfMatrix(matrix, row);
}
}
/*
run:
9 17 89 2 7 5
*/