title: How to make a function that counts the amount of equal values (in random position) inside a 2d array?
body: <p>I need to find how many people with the same name are sitting in certain chairs, chairs that are organized in a matrix.</p>
  
  <p>I made a small try, but I can`t get it to work. I know I'm basically doing "If 2 is 2, count++", but I don't know what other therms to use.</p>
  
  <p>This count should be 2, because there are two slots with the same data inside of them. (Maiz in 0,1 and 1,0)</p>
  
  <p>Any help would be appreciated! Thanks!</p>
  
  <pre><code>public class pru {
  public static void main (String[] args){
      String ejnombre[][]=new String[][]{
                          {"Juan", "Maiz"},
                          {"Maiz", "Luis"},
      };
      int count=0;
      for (int i=0; i&lt;ejnombre.length; i++){
          for(int j=0; j&lt;2; j++){
              if (ejnombre[i][j]==ejnombre[i][j]){
                  count++;
              }
  
          }
      }
      System.out.println(count);
  }
  }
  </code></pre>