Dear Prasanna,
Since Arrays are Objects they can be initialized using the new operator and when created Arrays are automatically initialized with the default value of their type.
Here in your case you have initialized the array with type of integer which takes the default value of 0.
See the following examples for default initilization
String[] s = new String[100]; // default values: null
boolean[] b = new boolean[4]; // default values: false
int[] i = new int[10][10]; // default values: 0
Array references declared as members are initialized to null BUT array references declared in methods are not initialized so they wont take the default value. Look at the following code
class TestArray {
int[] arr; // member declaration, initialized to 'null' and not 0
public static void main(String[] args) {
int[] arr1; // reference variable 'arr1' not initialized
// compiles ok
System.out.println("arr:" + new TestArray().arr);
// compile error
System.out.println("arr1: " + arr1);
}
}
I hope that I have been successful in explaining it and hope you understood. All the very Best !!!