title: Java - Find the row and column with the max sum
body: <p>As the title says, I want to know a way (in Java) to find which row (in a matrix/2D Array) and column has the highest sum of its numbers.
  There might be an easy solution but I'm struggling to find it.</p>
  
  <p>I currently have the first part of the program but I can't seem to find a solution to the second part, which is finding the row and column with the highest sum.</p>
  
  <p><a href="https://i.stack.imgur.com/0hKsn.jpg" rel="nofollow noreferrer">Desired output</a></p>
  
  <p>I'm a beginner at this so any kind of advice would be appreciated.</p>
  
  <p>This is the first part of my code:</p>
  
  <pre><code>import javax.swing.JOptionPane;
  
  public class summat{
      public static void main(String[] args){
          int mat[][] = new int [3][3];
          int num, sumop, sumw, i, j, mayop = 0, mayw = 0;
  
          for(i=0;i&lt;3;i++){
              for(j=0;j&lt;3;j++){
                  String input = JOptionPane.showInputDialog(null, "Products sold by the operator " +  (i+1) + " in week " + (j+1) + ".");
                  mat[i][j] = Integer.parseInt(input);
              }
          }
  
          /*Sum of individual rows*/
          for(i=0;i&lt;3;i++){
              sumop = 0;
              for(j=0;j&lt;3;j++){
                  sumop = sumop + mat[i][j];
              }
              JOptionPane.showMessageDialog(null, "The operator " + (i+1) + " sold " + sumop + " units.");
          }
  
          /*Sum of individual columns*/
          for(j=0;j&lt;3;j++){
              sumw = 0;
              for(i=0;i&lt;3;i++){
                  sumw = sumw + mat[i][j];
              }
              JOptionPane.showMessageDialog(null, "In week " + (j+1) + " the company sold " + sumw + " units.");
          }
  
      }
  }
  </code></pre>