if local variables need to be assigned some default value then why java provide default value for arrays declared locally.
import java.util.Arrays;
import java.util.Scanner;
public class MatrixMultiplication {
int a;
int a1[][]=new int[2][2];
public static void main(String[] args) {
int a2[][]=new int[2][2];
int b;
MatrixMultiplication mm=new MatrixMultiplication();
System.out.println(mm.a);
System.out.println(mm.a1[1][0]);
System.out.println(b);
System.out.println(a2[1][0]);
}
}
Like in above code for varible a default value is 0 and for b we have to setsome value. Then for a1[][] the dafult value of each element is 0. Till here everything is understood that have they are provided with deafult values but as a2[][] is locally declared then its elements should not be initialised by default as the java rule so how are they initialised by default with each element as 0