aspose file tools*
The moose likes Java in General and the fly likes dynamic class loading and generics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "dynamic class loading and generics" Watch "dynamic class loading and generics" New topic
Author

dynamic class loading and generics

jay vas
Ranch Hand

Joined: Aug 30, 2005
Posts: 407
Hi guys :

I have a class :

class A<T> { }

and I want to have a dynamic call to
T's constructor, i.e.

class A<T> { public T dynamic() {return T.class.newInstance(); } }

So my question is, how can I create an instance of a generic class
on the fly ?

Thanks!

Jay
Jean-Francois Briere
Ranch Hand

Joined: Mar 03, 2004
Posts: 101
One way would be to do:

Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dynamic class loading and generics