Using Class<?> Class.forName() generic info

Hi,

how do I get advantage of the generic information in Class.forName method?

I actually have the code:

Class<?> myClass= Class.forName(myString);

and I want a generic type for myClass (let T), so that later on I can create instances of myClass using:

T myInstance = myClass.newInstance();

How is this possible?

[361 byte] By [ntalamaia] at [2007-11-27 9:34:15]
# 1
You could tryClass<? extends T> clz = (Class<? extends T>)Class.forName(myString); // Note, above line needs suppresswarnings obv// Later on..T o = clz.newInstance();
alanmpa at 2007-7-12 22:58:02 > top of Java-index,Core,Core APIs...
# 2
Why don't just use Class<T> clz = (Class<T>)Class.forName(myString);T o = clz.newInstance(); ?
raindropa at 2007-7-12 22:58:02 > top of Java-index,Core,Core APIs...