Get super class name
import java.awt.Button;
public class Main {
public static void main(String[] args) {
Button o = new Button();
Class subclass = o.getClass();
Class superclass = subclass.getSuperclass();
while (superclass != null) {
String className = superclass.getName();
System.out.println(className);
subclass = superclass;
superclass = subclass.getSuperclass();
}
}
}
Output:
java.awt.Component
java.lang.Object
Home
Java Book
Runnable examples
Java Book
Runnable examples
Reflection Class:
- Class modifier: public, abstract or final
- Class simple name plus package name
- Create new instance
- Class reflection, all methods, constructors, parameters, interfaces
- Get super class name
- Get the class By way of .class
- Get unqualified class Name
- Is Type Compatible
- Is Primitive type
- Load a class given its name.