Getting the Superclass of an Object : SuperClass « Reflection « Java

Getting the Superclass of an Object

public class Main {
  public static void main(String[] argv) throws Exception {
    Object o = new String();
    Class sup = o.getClass().getSuperclass(); // java.lang.Object



Related examples in the same category

1.Superclass of Object is null
2.The superclass of primitive types is always null
3.Although the type of o2 is an interface, getSuperclass() returns the object's superclass
4.Retrieving other information through the class pointer
5.Return true if class a is either equivalent to class b, or if class a is a subclass of class b, i.e. if a either "extends" or "implements" b.
6.Allows the user to reflectively inspect an object hierarchy