Instead of setting the size of the array
B b[] = new B[10];
Set the size and add all 10 objects at all once.
B b[] = new B[] {new B(), new B(), new B(), new B(), new B(), new B(), new
B(), new B(), new B(), new B() };
"Stephen Mayes" <st*********@themayeshouse.us> wrote in message
news:2a*******************@bignews1.bellsouth.net. ..
class A{
class B{
boolean flag;
int value;
}
B b[] = new B[10];
public A(){
for (int i = 0; i < 10; i++)
b[i] = new B();
}
}
I'm wondering if there is a more elegant way to instantiate the elements
of b[] than the 'for' loop.