public class practwo {
public static void prac(int m[][]) {
int rows = m.length;
for (int i = 0; i < m[0].length; i++) {
int t = m[0][i];
m[0][i] = m[rows - 1][i];
m[rows - 1][i] = t;
}
}
public static void main(String[] args) {
int m[][] = new int[4][4];
m[][] = { {1,2,3,4},{1,2,3,4},{1,2,3,4},{1,2,3,4} };
prac(m);
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m[0].length; j++) {
System.out.println(+i + j);
}
}
}
}
Cannot figure out the error in the declaration line m[][]? I tried to swap first and last row of the matrix but showing error in the declaration line.