Home Java Reflect Finding out the super class name of the class



Finding out the super class name of the class
Posted on: February 28, 2008 at 12:00 AM
Here we show you the way to find out the Superclass name by using the getSuperclass() method. The given example demonstrates the use of getSuperclass() method in more detail.

Finding out the super class name of the class

     

Here we show you the way to find out the Superclass name by using the getSuperclass() method. The given example demonstrates the use of getSuperclass() method in more detail.

Create a class "Fsupercls". Po
pulate it with the Checkbox objects. Now retrieve the Superclass name by using the getSuperclass() method.

Here is the code of the Example :

Fsupercls.java: 

import java.lang.reflect.*;
import java.awt.*;

public class Fsupercls  {
 public static void main(String[] args) {
 Checkbox big = new Checkbox();
 printName(big);
 }
 static void printName(Object objct) {
 Class cls = objct.getClass();
 Class sup = cls.getSuperclass()
 System.out.println(sup);
 }
}

Here is the output of the Example :

C:\roseindia>javac Fsupercls.java

C:\roseindia>java Fsupercls
class java.awt.Component

Download this Example:

Related Tags for Finding out the super class name of the class:
cclassobjectcheckboxobjectsmethodfindgetnameusingaicreatecheckshowieexampleboxwithtotailexamsheilsupersuperitlsdemopopulateusetrieulpepopinnoasclsmouttrjclesretrieveemrcmehowobjrateratesfsdetaildetailxaxampssuperclasssuatlatekivmplgetseastrssrithshostctsfinkbjepleplndono


More Tutorials from this section

Ask Questions?    Discuss: Finding out the super class name of the class  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.