Fabricio Zelada wrote:Yeah right, I think I was not clear, in the begging I create object obj by using by common method (by calling the constructor).
But later I need to use its methods. The only reference of such object, its name, is contained into a String.
So I cannot use forName(String) method, because I will have to create other object. I would like to create a Class object that reference object obj. But only thing I have is its name inside the String. So is there any way?
The forName(String) method, only creates a Class object if it doesn't exist. And it doesn't create an instance of the object -- you have to use the Class object for that.
And BTW, you are completely not clear. Either you have a reference to the object or you don't. If you do, then use getClass(). If you don't, and have the name, then use "forName()". Or get a reference.
Henry