'How can I shift the rows of a 2d array down by 1 in java?

What would be the most basic way to shift the rows of a 2d array in java down by 1. The first row turns into the second row, the second row turns into the third row and the last row turns into the first one.

I tried this but it only lets me change two rows.

public static void switchRows(int[][] matrix, int K, int L){
   for (int i = 0; i < matrix[0].length; i++) {    
   // Swap two numbers
     int temp = matrix[K - 1][i];
     matrix[K - 1][i] = matrix[L - 1][i];
     matrix[L - 1][i] = temp;
   }
   // Print matrix
   for(int g = 0; g < matrix.length; g++){
      for(int b = 0; b < matrix[g].length; b++){
         System.out.print(matrix[g][b] + " ");
      }
      System.out.println();
   }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source