Since i had to read robert's email about 3 times before i got what he was saying, i'll elaborate in case anyone else is scratching their head as much as i was...
because you could write code that looks like this... for (int i = 0; i < arr.length; i++) { i = getSomeNumberNotBetweenZeroAndArrLength() String s = arr[i]; } ...the arr[i] lookup must do bounds checking and raise an exception if needed. This is not neccessary in the "foreach" style construct where there is no explicit loop counter. : When iterating over an array using an indexed loop, you typically need to : access the element, as follows: : : for(int i=0;i<100;i++) { : String s = array[i]; : ... : } : : Java performs bounds checking on the array[i] access to make sure i is within : the limits of the array. Granted, there are optimizations the JVM can do in : many cases using escape processing to know that i will always be in the range, : but it is not always feasible. : : when you use : : for(String s : array) { : } : : the JVM uses its own internal indexer that it knows cannot be outside the : bounds, and thus the bounds checking can be avoided. -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]