0

Hello i used of answer in this question : Create new class from a Variable in Java to create by code a new class with name taked by variable. My question is how can i add inheritance to this new class?I already have the parent class and i want the new to be its child and inheritate all the methods.I've checked the Class Class in java.lang but it doesn't have something about setparent class or something like that.I understand that is very unsafe logic but i really want this feature in my application.Any ideas?

Community
  • 1
  • 1
user842624
  • 7
  • 1
  • 6

1 Answers1

0

Just to clarify, and correct me if I'm wrong but are you trying to dynamically create a class that doesn't already exist or trying to instantiate an instance of a class from a String? Using classForName("Foo") is not going to create a new type that doesn't already exist, it's going to look through your classpath for a class named Foo and create an instance of its class object that you can then call methods on.

Rick Mangi
  • 3,761
  • 1
  • 14
  • 17
  • I'm trying to dynamically create a class that inheritates a parent class.Is this possible?I don't want instances. – user842624 Feb 24 '12 at 15:28
  • Thx Rick but my project is an android project but i didn't tell it cause this was a java subject.Do you know if it is possible to work in an android project? – user842624 Feb 24 '12 at 15:34