This is just a dummy code. I fail to understand what is wrong as I am new to JAVA.
I have already referred: What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? The answers there only pertain to using wrong length indices.
Code:
class abc{
    static int n;
    static int[] arr=new int[n];
    static void print_arr(){
        for(int x: arr) System.out.print(x+" ");
    }
}
class Main {
    public static void main(String[] args) {
        abc.n=5;
        for(int i=0;i<abc.n;i++){
            abc.arr[i]=10;
        }
        abc.print_arr();
    }
}
I want this code to print 10 five times.
 
     
    