J
Joona I Palaste
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);
}
Should print "Hello, world!");
--
/-- Joona Palaste ([email protected]) ---------------------------\
| 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
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);
}
Should print "Hello, world!");
--
/-- Joona Palaste ([email protected]) ---------------------------\
| 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