title: Get the sum of each individual row and column in a 2D array
body: <p>I have the sum of one row and one column but I am looking to find the sum of each row and column individually. For example the output would be "Sum of row 1 is.. Sum of row 2 is.. and so forth. Same goes for the columns as well.   </p>
  
  <pre><code>public class TwoD {
  
    public static void main(String[] args) {
      int[][] myArray = { {7, 2, 10, 4, 3},
                          {14, 3, 5, 9, 16},
                          {99, 12, 37, 4, 2},
                          {8, 9, 10, 11, 12},
                          {13, 14, 15, 16, 17}                
      };
  
      int row = 0;
      int col;
      int rowSum = 0;
      int colSum = 0;
  
      for(col = 0; col&lt;5;col++)
        rowSum = rowSum + myArray[row][col];
         for( row = 0; row&lt;5; row++)
          System.out.println("Sum of row " + row + " is " + rowSum);
  
      col = 0;
      for(row=0; row&lt;5;row++)
       colSum = colSum + myArray[row][col];
        for(col = 0; col&lt;5; col++)
         System.out.println("Sum of column " + col + " is " + colSum);    
    }
  }
  </code></pre>