On Thu, Jan 6, 2011 at 3:47 AM, Carl Jokl <[email protected]> wrote:

>
> I use mostly foreach loops but there is one situation in Java where I
> seem stuck with using the indexed version. This may be a shortcoming
> in Java because the order in which iteration is done does not matter.
>

I don't think this has anything to do with the language. The question is:
does the business logic inside your loop need to know the current index or
not? In the example you give below, the answer is clearly yes. I can think
of a few other examples where indices are necessary, but from my experience,
they are more the exception than the norm.

In most cases, foreach loops are enough and a great improvement over index
based loops (but not because of parallelism, as I explained in my previous
email).

-- 
Cédric

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to