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:
for (int i = 0; i < turtles.size(); i++) {
if (turtles.get(i).getX() == 450) {
results.add(turtles.get(i).indexOf(i)); //this line error
}
}
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?
The error is saying:
cannot find symbol
symbol: method indexOf(int)
location: class se.lth.cs.pt.turtle.visible.Turtle
results.add(turtles.get(i).indexOf(i));
>