get Class Super Class - Java Reflection

Java examples for Reflection:Class

Description

get Class Super Class

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        Class classInstance = String.class;
        getClassSuperClass(classInstance);
    }//www  .j  a  va  2s .c  o m

    public static void getClassSuperClass(Class<?> classInstance) {
        Class supClass = classInstance.getSuperclass();
        if (supClass != null) //super class
            System.out.print(" extends " + supClass.getName());

    }
}

Related Tutorials