Dev Discussion > Google suggests using the "enhanced" for loop by default.

Hi Matt, when you mentioned why you use an iterator to go through your Hearts ArrayList, it didn't sound right to me.

I checked Google's perf recommendations again and they actually suggest using the "enhanced" for loop. From http://developer.android.com/guide/practices/design/performance.html#foreach:

"To summarize: use the enhanced for loop by default, but consider a hand-written counted loop for performance-critical ArrayList iteration."

Thanks for the love day code walkthrough,
William

February 20, 2011 | Unregistered CommenterWilliam Cheung

Thanks a lot William, great find! They mention that the enhanced for loop is the equivalent to an Iterator because it creates one anyways. I guess I will change my ways if that's the case.

February 21, 2011 | Registered CommenterMobicartel