Basically the title says it all.
Why does using a primitive data type work in the second "for-each" loop when I am looping over an array of objects. Is there a casting back to the primitive equivalent of the Integer object occurring behind the scenes?
import java.util.Arrays;
import java.util.Collections;
public class CodeTestingClass
{
public static void main(String[] args)
{
Integer[] array = {1,2,3,4,5};
Collections.rotate(Arrays.asList(array), 1);
System.out.println(Arrays.toString(array) + "\n" );
for(Integer i : array)
{
System.out.print(i);
}
System.out.print("\n");
for(int i : array)
{
System.out.print(i);
}
}
}