File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "dynamic class loading and generics" Watch "dynamic class loading and generics" New topic

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 ?


Jean-Francois Briere
Ranch Hand

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

I agree. Here's the link:
subject: dynamic class loading and generics
It's not a secret anymore!