I wrote a simple retrieval for loop for array list
int[] a = new int[5] ;
for(int d:a)
{
Arrays.fill(a, 111);
System.out.print(d);
}
The output of above code is 0111111111111
.
I just can't figure out what is that 0 doing. My expected output is 111111111111
.
When I write the same code using simple for loop
int[] a = new int[5] ;
for(int i=0;i<a.length;i++)
{
Arrays.fill(a, 111);
System.out.print(a[i]);
}
it meets my expectation. I would like to know where I'm wrong.