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 understand this? Thanks in advance.
int[] number = new int[10];
for(int i: number) {
}
The loop is equivalent to:
for(int j = 0; j < number.length; j++) {
int i = number[j];
...
}
where j is an internally generated reference that does not conflict with normal user identifiers.