title: Trying to get the max/min in array
body: <p>Im trying to get the min value in a column in the row of the max value. Im trying to using for loops but its not working. </p>
  
  <p>Let say a matrix A:</p>
  
  <p>3 4 5<br>
  2 3 4<br>
  1 2 3</p>
  
  <p>I want the program to find the max value in the [0]th row then find the min value in the colunm of the max.
  So result should be : max of row [0] = 5, min of column [2] = 3.
  I then want it to do the same of all the rows, that why I ysed a while loop.</p>
  
  <p>Here is the matrix:</p>
  
  <pre><code>public int[][] createMatrix(int a, int b){
      Scanner  inputm = new Scanner(System.in);
    A = new int[a][b];  
  System.out.println("Enter elements for matrix A : ");
  for (int i=0 ; i &lt; A.length ; i++){
      System.out.println("Enter numbers for " + i +"th row");
  for  (int j=0 ; j &lt; A[i].length ; j++){
  A[i][j] = inputm.nextInt();
  
      }
  
  }
  return A;
  }
  
  public int[][] displayMatrix(){
   System.out.println("Matrix A: ");
  
      for (int i=0 ; i &lt; A.length ; i++)
      {     System.out.println();
          for  (int j=0 ; j &lt; A[i].length ; j++){
              System.out.print(A[i][j]+" ");
                }
      }
  
  
  return A;
  
  }
  
  
  public int getMaximumOfEveryRow (int c){ 
      a=c;
  int i= 0;
  int j;
   while(i &lt; A[a].length){
  
      max = Integer.MIN_VALUE;
      for (  j = 0; j &lt; A [ i ].length; j++ )
          if ( A [ i ] [ j ] &gt; max ){
              max = A [ i ] [ j ];
          }
  
  
  
              for (  i = 0; i &lt; A [ i ].length; i++ )// e
          if ( A [ i ] [ j ] &lt; min ){
              min = A [ i ] [ j ];
          }
  
          System.out.println( "\n Maximum of row " + j + " = " + max );
      System.out.println( "Minimum of column " + i + " = " + min );        
      if(max == min){
      System.out.println( min+ " = " + max );
      System.out.println( "This is a saddle point. ");
      }
  
  
  
  
      i++;
  
   }     
  return max;
  
  
  }
  </code></pre>
  
  <p>and this is what I have so far:</p>
  
  <pre><code>public int getMaximumOfEveryRow (int c){ 
      a=c;
  int i= 0;
  int j;
   while(i &lt; A[a].length){
  
      max = Integer.MIN_VALUE;
      for (  j = 0; j &lt; A [ i ].length; j++ )
          if ( A [ i ] [ j ] &gt; max ){
              max = A [ i ] [ j ];
          }
  
  
      int e = j;  
      int r;
              for (  i = 0; i &lt; A [ i ].length; i++ )// e
          if ( A [ i ] [ j ] &lt; min ){
              min = A [ i ] [ j ];
          }
  
          System.out.println( "\n Maximum of row " + j + " = " + max );
      System.out.println( "Minimum of column " + i + " = " + min );        
      if(max == min){
      System.out.println( min+ " = " + max );
      System.out.println( "This is a saddle point. ");
      }
  
  
  
  
      i++;
  
   }     
  return max;
  
  
  }
  public int getMaximumOfEveryColumn ()
  {
  for ( int i = 0; i &lt; A.length; i++ )
  {
      maxc = Integer.MIN_VALUE;
      for ( int j = 0; j &lt; A [ i ].length; j++ )
          if ( A [ j ] [ i ] &gt; maxc )
              maxc = A [ j ] [ i ];
      System.out.println( "Maximum of column " + i + " = " + maxc );
  }
  return maxc;
  }
  
  public int getMinimumOfEveryColumn_(){
  for ( int i = 0; i &lt; A.length; i++ )
  {
      minc = Integer.MAX_VALUE;
      for ( int j = 0; j &lt; A [ i ].length; j++ )
          if ( A [ j ] [ i ] &lt; minc )
              minc = A [ j ] [ i ];
      System.out.println( "Minimum of column " + i + " = " + minc );
  }
  return minc;
  }
  public int getMaximumOfEveryRow ()
  {
  for ( int i = 0; i &lt; A.length; i++ )
  {
      maxr = Integer.MIN_VALUE;
      for ( int j = 0; j &lt; A [ i ].length; j++ )
          if ( A [ i ] [ j ] &gt; maxr )
              maxr = A [ i ] [ j ];
      System.out.println( "Maximum of row " + i + " = " + maxr );
  }
  return maxr;
  }
  </code></pre>
  
  <p>code for finding the max value in colunm and then finding the min value in the row of that max value.</p>
  
  <pre><code>public void get_max_of_the_row_of_local_min ()
  {
   for ( int i = 0; i &lt; A.length; i++ )
   {
      min = Integer.MAX_VALUE;
      max = Integer.MIN_VALUE;
      int index_of_min_in_its_col = 0;
  
  
  
      //maxc = Integer.MIN_VALUE;
      for ( int j = 0; j &lt; A [ i ].length; j++ )
  
          if ( A [ j ] [ i ] &gt; max ){
              max = A [ j ] [ i ];
              index_of_min_in_its_col = i;
              System.out.println( " Maximum of col [" + i + "] = " + max);
          }
  
     for ( int j = 0; j &lt; A [ index_of_min_in_its_col ].length; j++ )
  
          if ( A [ index_of_min_in_its_col ] [ index_of_min_in_its_col ] &lt; min ){
              min = A [ index_of_min_in_its_col ] [ index_of_min_in_its_col ];
     a =j;
          }
      //System.out.print( " Maximum of col [" + j + "] = " + max);
      System.out.println( " Minimum of rol [" + index_of_min_in_its_col + "] = " + min );
  
      if(max == min){
      System.out.println("This is a saddle point.");
      }
  
   }
  </code></pre>