I am trying to output arrays using enhanced for loop. I want it to be printed as;
a[0] = 5, a[1] = 8, ... and so on.
This is my code;
int[] a = {5, 8, 10, 24, 45};
for(int i=0 ;i <= 4; i++) {
for(int enhancedfor : a) {
System.out.print("a[" + i + "] = " + enhancedfor + ", ");
}
}
I actually want, once it outputs value of a[0], instead of again going for same loop, it should go to first for statement , and then second ...
Any help guys ?