I understand that new for each loop works with Iterable and arrays, but I don\'t know what goes behind the scenes when working with arrays.
Can anyone help me under
This is the equivalent to:
final int len = number.length;
for(int j = 0; j < len; j++) {
int i = number[j];
}
Note that the forEach will not evaluate the .length in each loop. This might be also be eliminated by the JVM, but especially in case of collections, where some would use
for(int j = 0; j < collection.size(); j++) {
it makes a (small) difference to the faster
int len = collection.size()
for(int j = 0; j < len; j++) {