1

Is there a way to create new instance of generic type using java , i have used type resolver to get the parametrized and i was able to get it. type but whenever i call this.myclass.newInstance() an instantiation exception is raised. i know the same question is asked but no answer has solved my problem. Pre Thanks.

Mohammed Falha
  • 967
  • 8
  • 22
  • How about MyClass.newInstance()? – shaunw Jun 06 '13 at 20:54
  • 2
    What *exact* exception was raised? Type erasure actually makes constructing an instance of a generic type with reflection relatively straightforward - you don't need to specify the type arguments because the object isn't aware of them. – Jon Skeet Jun 06 '13 at 20:54
  • http://docs.oracle.com/javase/tutorial/reflect/member/ctorInstance.html – shaunw Jun 06 '13 at 20:55
  • 1
    dup http://stackoverflow.com/questions/1090458/instantiating-a-generic-class-in-java – Amir Afghani Jun 06 '13 at 20:55
  • 7
    Your question is missing two important things: Post your **Code** and the **full stack trace** – BackSlash Jun 06 '13 at 20:55

0 Answers0