On Tue, 2008-04-08 at 18:48 -0500, robert engels wrote: > That is opposite of my testing:... > > The 'foreach' is consistently faster. The time difference is > independent of the size of the array. What I know about JVM > implementations, the foreach version SHOULD always be faster - > because the no bounds checking needs to be done on the element access...
That's interesting. Even if it doesn't show in a performance-test right now, it might do so in later Java versions. As for your test-code, then it does not measure performance in a fair way, as the foreach runs after the old-style loop. I'm sure you'll see different results if you switch the order of the two tests. I'm a big fan of foreach, but I'll have to admit that Steven's observations seems to be correct. I hope I'll find the time to take the advice of Yonik and make my own test sometime soon. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]