• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help reqd in reflection API

 
Devesh H Rao
Ranch Hand
Posts: 687
Hibernate jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have the following two classes....
public class ParentClass{
}
public class ChildClass extends ParentClass{
}
Some code in some main method in some class

// code
Class c = Class.forName("ChildClass");
Class parentC = c.??? ; //
// Code end
I need to get the class inherited by the child class ie the Parentclass using reflection can anyone help me out on this.
c.getSuperClass dosent work....
Thanks.
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is getSuperclass() not getSuperClass() (Note the case).
 
Devesh H Rao
Ranch Hand
Posts: 687
Hibernate jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mani Ram:
It is getSuperclass() not getSuperClass() (Note the case).

It was just a typo error while posting message..
i tried the getSuperclass() which returned java.lang.Class which is not what i want.
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Devesh H Rao:

i tried the getSuperclass() which returned java.lang.Class which is not what i want.

How you made sure that it returned java.lang.Class. Here is what I did



I get the output as class ParentClass
 
Devesh H Rao
Ranch Hand
Posts: 687
Hibernate jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mani Ram:
I get the output as [b]class ParentClas

Instead of parentClass.getName() I did parentClass.getClass() no doubt i got java.lang.Class.
Thanks mani...
They say stupidty has no limits i think i just raised the benchmark
[ February 19, 2004: Message edited by: Devesh H Rao ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic