public class A{
int val;
public A(int val){
this.val = val;
}
public void print() {
System.out.println(val);
}
public static void main(String args[]){
A[] aList = new A[10];
int temp =1;
for(A a : aList){
a = new A(temp++);
}
for(A a : aList){
a.print();;
}
}
}
Getting Exception in thread "main" java.lang.NullPointerException at A.main(A.java:28) aList address space Class A objects are stored but again iterate unable to get stored objects, where are the objects stored ?