I have not been able to figure this out for quite sometime now after searching a lot of forums online.
I have a class A and a nested class B in a File A.java Also another class C in File C.java
Now I declare an array of object B in class A but I can neither access nor initialize the array elements in Class A or Class C.
public class A{
public B b[] = new B[15]; //compiles
b[0] = new B(); //does not compile
// b[0] = this.new B(); //does not compile either
public class B{
}
}
Now in Class C, if I do the following:
public class C{
A a = new A(); //compiles
a.b[0] = a.new A.B(); //does not compile
}
Can anyone please help? I think I am doing some basic error in syntax while trying to access nested instance arrays. Thanks!