code stench

Don’t iterate to find an index. Why? You already know the index.

int toFind = ...;
for (int i=0;i

Just use array[toFind].doSomething(). Iterate only when you are matching some other non-index attribute.

The same applies even if you have lists, or if you're looking for toFind-1.

Leave a Reply

Your email address will not be published.