collection-based for loop
Can somebody explain to me why only the first code snippet is valid?
A.
int[] a={2,3,5,7};
for(int i : a) System.out.println(i);
B.
int[] a={2,3,5,7};
int i;
for(i : a) System.out.println(i);
Can somebody explain to me why only the first code snippet is valid?
A.
int[] a={2,3,5,7};
for(int i : a) System.out.println(i);
B.
int[] a={2,3,5,7};
int i;
for(i : a) System.out.println(i);