
15 Oct
2008
15 Oct
'08
9:43 p.m.
On 16 Oct 2008, at 9:01 am, Daryoush Mehrtash wrote:
I am not sure how say in a Java language a constructor can "conjure up a value of an unknown type".
... Class anUnknownClass; Object anInstance; anInstance = anUnknownClass.getConstructor().newInstance(); If you know that the constructor will require arguments of types T1 and T2, and you have suitable values v1, v2, anInstance = anUnknownClass.getConstructor(T1, T2).newInstance(v1, v2); will do the job.