title: java - get index of element in array [error]
body: <p>When i am trying to receive the index of the element i get an error when compiling (cannot find symbol on the code that i have marked with comment). I have the following code:</p>
  
  <pre><code>        for (int i = 0; i &lt; turtles.size(); i++) {
  
                  if (turtles.get(i).getX() == 450) {
  
                          results.add(turtles.get(i).indexOf(i)); //this line error
                  }
          }
  </code></pre>
  
  <p><strong>The thing is that i want to add the index of the retrieved turtle in the loop into a new array called results. How do i do that?</strong></p>
  
  <p>The error is saying:</p>
  
  <p>cannot find symbol</p>
  
  <p>symbol: method indexOf(int)</p>
  
  <p>location: class se.lth.cs.pt.turtle.visible.Turtle</p>
  
  <pre><code>                        results.add(turtles.get(i).indexOf(i));
                                                    &gt; 
  </code></pre>