File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic class loading and generics

 
jay vas
Ranch Hand
Posts: 407
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way would be to do:

Regards
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic