title: Separate methods for matrix and swapping diagonals
body: <p>I am supposed to create a matrix and split it into 3 methods, where first one will read matrix, second will print matrix and third one will swap diagonals. Read matrix works but I've tried to pass the parameters to other methods so they can work too but when I call them in main class, it doesn't work.</p>
  
  <pre><code>    public static void readMatrix() {
  
      Random rand = new Random();
      Scanner in = new Scanner(System.in);
      System.out.println("Please insert how many rows and columns you want for matrix");
      int ColumnsAndRows = in.nextInt();
  
      int matrix[][] = new int[ColumnsAndRows][ColumnsAndRows];
  
      for (int row = 0; row &lt; matrix.length; row++) {
          for (int column = 0; column &lt; matrix[row].length; column++) {
              matrix[row][column] = rand.nextInt(ColumnsAndRows * ColumnsAndRows) + 1;
  
          }
      }
  
  }
  
  public int[][] printMatrix(int matrix[][]) {
  
      for (int row = 0; row &lt; matrix.length; row++) {
          for (int column = 0; column &lt; matrix[row].length; column++) {
              System.out.print(matrix[row][column] + " ");
  
          }
          System.out.println("");
      }
      return matrix;
  }
  
  public int[][] swapDiagonals(int ColumnsAndRows, int matrix[][]) {
      for (int i = 0; i &lt; ColumnsAndRows; i++) {
      int temp = matrix[i][i];
      matrix[i][i] = matrix[i][ColumnsAndRows - i - 1];
      matrix[i][ColumnsAndRows - i - 1] = temp;
      }
      printMatrix(matrix);
      return matrix;
  </code></pre>