title: How do I fill a 2D array with random integers [1,9] and print out a 2D array with sums of rows at each row and sum of columns at each column?
body: <p>The following code is what I have so far, and nothing is working at all. I am intend to Declares a 7×10 two dimensional array in the main. Pass that array to a method which fills the array with random integers [1,9]. Pass the filled array to a method which prints the two dimensional array with the sum of the row at the end of each row and the sum of the column at the end of each column. Row and column labels must also be printed. Any help will be greatly appreciated.</p>
  
  <pre class="lang-java prettyprint-override"><code>package twodimensionalarray;
  
  import java.util.Arrays;
  import java.util.Random;
  
  /**
   *
   * @author Kristy7
   */
  public class TwoDimensionalArray {
  
      //This method is for generating random integers between 1 and 9.
      public static int randInt(){
          Random rand = new Random();
          int randNum;
          randNum = rand.nextInt(9)+1;
          return randNum;
  
      }
  
      //This method is for filling a 2D array with random integers 
      public static int[][] fillArray(int[][] toFill){
          int[][] toReturn = new int[0][0];
  
          for(int r = 0; r &lt; toFill.length; r++){
              for(int c = 0; c &lt; toFill[0].length; c++){
                  toReturn[toFill[r]][toFill[c]] = randInt(toFill);
              }
  
          }
  
          return toReturn;
      }
  
      //This method is for for summing rows and columns, and printing rows, columns, the sum of ruws at each row, and the sum of columns at each column.
      public static void summingRC(int[][] toSum){
          int[] colSums = new int[0];
          for(int i = 0; i &lt; toSum.length; i++){
              System.out.print(i);
          }
          System.out.println();
          int sum = 0;
      for (int r = 0; r &lt; toSum.length; r++) {
  
          for (int c = 0; c &lt; toSum[r].length; c++) {
              sum += toSum[c][r];
              colSums[c] += toSum[r][c];
          }
  
          System.out.println(sum);
      }
      System.out.println(colSums);
  
  
      }
  
      /**
       * @param args the command line arguments
       * 
       */
  
      public static void main(String[] args) {
  
          //Declare a 7x10 2D array 
          int [][] twoDArray = new int[7][10];
  
          //call fillArray method.
          int[][] fillingArray = fillArray(twoDArray);
  
          //call SummingRC method
          summingRC(fillingArray);
  
      }
  
  }
  </code></pre>