There was a big DOH when I read the first reply. However with the old for loop (Which is tried and tested) I can do the following But with the so called Enhanced for loop I can't do the following Maybe this will be sorted for the next really enhanced for loop
Guys, I found this useful info from Sun's Official Page about J2SE 5.0 new features.
So when should you use the for-each loop? Any time you can. It really beautifies your code. Unfortunately, you cannot use it everywhere. Consider, for example, the expurgate method. The program needs access to the iterator in order to remove the current element. The for-each loop hides the iterator, so you cannot call remove. Therefore, the for-each loop is not usable for filtering. Similarly it is not usable for loops where you need to replace elements in a list or array as you traverse it. Finally, it is not usable for loops that must iterate over multiple collections in parallel. These shortcomings were known by the designers, who made a conscious decision to go with a clean, simple construct that would cover the great majority of cases.
Hope this is informative to ranchers out here. The original page can be accessed here!