Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enhanced For Loop and Iterator

 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CODE 1



CODE 2




Besides readability, is there any performance improvement using the second code ?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope, just syntactic sugar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic