This is just one solution for your reference
public static void printMatrix(int [][] a, int row, int col){ int minK = rowk; j--) System.out.print(a[row-1-k][j]+" "); for(int i=row-k-1; i>k; i--) System.out.print(a[i][k]+" "); } System.out.println(); }