Sorry, but Java doesn't do that for you. Array creation only creates the arrays themselves, but cannot fill them with anything but null
. You have to loop through the created arrays manually and create instances to fill them.
Furthermore, however, your example code wouldn't compile to begin with, since you don't specify the size of the array.
What you want, then, is probably something akin to this:
int d1 = 5, d2 = 6; /* Or however large you want the arrays to be. */
myBArr = new B[d1][d2];
for(int i1 = 0; i1 < d1; i1++) {
for(int i2 = 0; i2 < d2; i2++) {
myBArr[i1][i2] = new B(this);
}
}