title: Return the index of an arbitrary Object in a 2d array java.
body: <p>I'm trying to find the index of an object placed in an array. The array has been populated like this</p>
  
  <pre><code>for(i = 0 ; i&lt;n ;i++){
      for(j=0; j&lt;n ;j++){
          squares[i][j]= new Square(i,j)
          }
  </code></pre>
  
  <p>So the array is basically full of Square objects with no name. I want to make a method that returns the index of a square object, like: </p>
  
  <pre><code>getObject(Square s){
  {
  </code></pre>
  
  <p>I've seen other answers calling for the use of</p>
  
  <pre><code>Arrays.asList(array)
  </code></pre>
  
  <p>And stuff like that, but they all try to return the index for an int or a String.</p>
  
  <p>How should i go about returning the index for any object?</p>