aspose file tools*
The moose likes Performance and the fly likes Enhanced For Loop and Iterator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Enhanced For Loop and Iterator" Watch "Enhanced For Loop and Iterator" New topic
Author

Enhanced For Loop and Iterator

Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

CODE 1



CODE 2




Besides readability, is there any performance improvement using the second code ?


Time is what we want the most, but what we use the worst. -- William Penn
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Robin John wrote:
Besides readability, is there any performance improvement using the second code ?


No. The enhanced for loop uses the iterator anyway, so the generated byte code ends up the same.
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1779
    
    7

Nope, just syntactic sugar.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enhanced For Loop and Iterator