Local variable array of ints defaults to zero [duplicate]

This question already has an answer here:

Why is it that when an array of ‘ints’ is made as a local variable they default to zero?

       public static void main(String [] args) {
           int []arrayInts = new int[5];
           for(int i: arrayInts)
                System.out.println(i);
           //Prints out zeros 
       }

While if an ‘int’ variable is declared as a local variable it does not get initialized.

       public static void main(String [] args) {            
           int a;
            System.out.println(a);
           //Compilation error: The local variable a may not have been initialized
       }