You can't. You need to keep track of the index.
int[] nums = new int[]{1, 2, 3, 4, 5};
int index = 0;
for (int i: nums) {
System.out.println(index + ": " + i);
index++;
}
You can't. You need to keep track of the index.
int[] nums = new int[]{1, 2, 3, 4, 5};
int index = 0;
for (int i: nums) {
System.out.println(index + ": " + i);
index++;
}