Use nested for loops to traverse over the entire matrix. Remember this pattern for all 2D array problems :
int rows = matrix.length and int columns = matrix.length. Once you have the row / column dimensions, write 2 for loops that traverse the entire matrix. In the inner for loop, use a temporary variable to make the swap.