集册 Java实例教程 打印超类

打印超类

欢马劈雪     最近更新时间:2020-01-02 10:19:05

388
打印超类


//package com.nowjava;
/*
N o  w  J a v a . c o m - 时  代  Java 提 供
*/


import static java.lang.System.out;


public class Main {

    public static void printSuperclass(Class<?> c) {

        Class<?> superClass = c.getSuperclass();

        if (null != superClass) {

            out.format("Superclass => %s", superClass.getName());

        } else {

            out.format("Superclass => No superclass");

        }

        out.format("%n%n");

    }

}