N
NAJH
I'm a newbie and therefore have an unfortunately dumb question...
In some languages I've used I've been able to create or reference
variables in a dynamic way, in order to build them up formulaicly...
I'd like to know how to do that in Java. So lets say I had a for loop
and I wanted to create 20 objects with names myObj1...myObj20:
I'd do...
for (int i = 0; i <20; i++)
{
SpecialObject "myObj" + i = new SpecialObject();
}
....but obviously that's not right, because I just made that up, but can
you see what I'm trying to acheive?
Many thanks!
Neil
In some languages I've used I've been able to create or reference
variables in a dynamic way, in order to build them up formulaicly...
I'd like to know how to do that in Java. So lets say I had a for loop
and I wanted to create 20 objects with names myObj1...myObj20:
I'd do...
for (int i = 0; i <20; i++)
{
SpecialObject "myObj" + i = new SpecialObject();
}
....but obviously that's not right, because I just made that up, but can
you see what I'm trying to acheive?
Many thanks!
Neil