Specifications
Sun Services
Java™ Programming Language
Module 9, slide 35 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Enhanced for Loop
The enhanced for loop has the following characteristics:
• Simplified iteration over collections
• Much shorter, clearer, and safer
• Effective for arrays
• Simpler when using nested loops
• Iterator disadvantages removed
Iterators are error prone:
• Iterator variables occur three times per loop.
• This provides the opportunity for code to go wrong.










