0
Is there any way to know the index number when using this enhanced for loop?
1 Réponse
+ 1
No. You would need to declare an index counter to track the index position. And if you do that, you might as well just use a regular for loop:
int index = 0;
for (int x : arr) {
// whatever you want to do with x
index++;
}