How do I create a certain amount of instances at runtime?
If i want a certain amount of instances at runtime, how can i do it?
say, if i write a program that read an input from a keyboard and create a certain amount of instances. or read an input from a keyboard to be an instance variable.Can i do it? How? Please help!
[276 byte] By [
Spongeboya] at [2007-11-27 11:18:07]

> If i want a certain amount of instances at runtime,
> how can i do it?
>
> say, if i write a program that read an input from a
> keyboard and create a certain amount of instances.
> or read an input from a keyboard to be an instance
> variable.Can i do it? How? Please help!
How much instance do you want? 1 gm? 10 gms? 1 pound? a kilo?
> If i want a certain amount of instances at runtime,
> how can i do it?
int numInstances = getNumInstancesFromSomewhere();
List<Foo> fooList = new ArrayList<Foo>(numInstances);
for (int ix = 0; ix < numInstances; ix++) {
fooList.add(new Foo());
}
jverda at 2007-7-29 14:29:02 >
