Suppose I have a Java Class object denoting some Java class. I would
like to dynamically create an *array* of references to the class that
the Class object denotes. The size of the array should also be given in
the creation. What is the easiest way of doing this?
Example of what I have in mind:
Class c = "Hello, world!".getClass();
String[] array = /* what the heck do I write here? */;
array[0] = "Hello, world!";
for (int i=0; i<array.length; i++) {
System.out.println(array[i]);
}
Should print "Hello, world!");

Signature
/-- Joona Palaste (palaste@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"The truth is out there, man! Way out there!"
- Professor Ashfield
David Zimmerman - 30 Sep 2003 13:16 GMT
> Suppose I have a Java Class object denoting some Java class. I would
> like to dynamically create an *array* of references to the class that
[quoted text clipped - 11 lines]
>
> Should print "Hello, world!");
Array.newInstance(Class, int)
Joona I Palaste - 30 Sep 2003 13:23 GMT
David Zimmerman <dzimm@hiddenmind.com> scribbled the following:
>> Suppose I have a Java Class object denoting some Java class. I would
>> like to dynamically create an *array* of references to the class that
>> the Class object denotes. The size of the array should also be given in
>> the creation. What is the easiest way of doing this?
> Array.newInstance(Class, int)
Thanks!

Signature
/-- Joona Palaste (palaste@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"The obvious mathematical breakthrough would be development of an easy way to
factor large prime numbers."
- Bill Gates