Class obj1 = new Class() In above statement obj1 is object reference. If number of such object references needed at run-time is not known at compile time, how would you come up with next object reference e.g. obj2? In other words, can you put a function call in place of obj1 that return new name. I know you can use arrays but they are also fixed length. I have little knowledge that there are some container that adjust their size at run-type. Any other idea? Thanks Barkat Mardhani
Barkat Check out the Vector and the ArrayList classes. They are both resizable collections. so you could generate a number of object references at run time with out knowing in advance how many you were going to need. Of course, in many cases, you can do this with an array too, you just dont declare the array until you know how big it is going to be.