This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
There is a not-well-known problem with the for-each (enhanced for) loop: an assignment in the loop like that doesn't seem to work. You have to regard the for-each loop as "read only." You don't get any compiler warnings nor exceptions, which I find annoying. It isn't in the Java� Tutorials, but it's in Deitel and Deitel (6th edition page 303)
Note, however, that the enhanced for statement can be used only to access array elements-it cannot be used to modify elements.
Horstmann and Cornell (7th edition vol I page 82) says
The enhanced for loop . . . sets the given variable to each elements of the collection and then executes the statement (which, of course, may be a block).
That suggests you might get a copy reference; if you change that you don't change the original array/collection. [ November 12, 2008: Message edited by: Campbell Ritchie ]