Overview:
I'm using for-each loops and I'm curious if I need to replace them with regular for
loops, or if there is a way to do a locate in an ArrayList
which will give me the equivalent of keeping track of the index which is used in normal for
loops.
Simplified Version of the Problem:
I'm using for-each with an ArrayList
of objects. These objects are used to calculate different values at different times, so I need to iterate through the items and do the calculates a couple different times. I wish to track these results in a structure, which I can easily do, if I can locate items in an ArrayList
(without having to iterate through everything in a separate loop). If there is, then I can use that to build what I need. If not, I'll replace the for-each with for
loops and get the functionality I need.