title: How to check in 2d array if all elements in row and column are the same?
body: <p>I am trying to write a code in java that would look if all elements in a row and column are the same and print out the indexes of it.</p>
  
  <p>So for example if I had two dimensional array of </p>
  
  <pre><code>{ 1, 0, 0, 0, 0}
  { 1, 0, 0, 0, 0}
  { 1, 1, 1, 1, 1}
  </code></pre>
  
  <p>I want to print out 2,0 which means that in the row 2 all the elements are the same and in column 0 all the elements are the same too and they are equal to each other.</p>
  
  <p>I was trying to do it with for statements</p>
  
  <pre><code>int[][] array_1 = { {1}, 
                      {1} };
  for(int row=0; row&lt;array.length-1; row++){
      for (int col=0; col&lt;array[0].length-1; col++){
          if(array[row][col]==array[row+1][col]&amp;&amp;
             array[row][col]==array[row][col+1]&amp;&amp;
             array[row][col]==array_1[0][0]) {
               System.out.print(row);
               System.out.println(col);      
          }
      }
  }
  </code></pre>
  
  <p>but it does not work because it does not check all the rows and columns, it stops somewhere in the middle and I have no idea what that is happening. </p>
  
  <p>Do you have any suggestions? </p>