📜  打印 java 对象继承的类 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:09.814000             🧑  作者: Mango

代码示例1
//package com.java2s;

import static java.lang.System.out;

public class Main {
    public static void printInheritanceTree(Class c) {
        out.format("Inheritance Tree => %n");
        Class ancestor = c.getSuperclass();

        while (ancestor != null) {
            out.format("  %s%n", ancestor.getCanonicalName());
            ancestor = ancestor.getSuperclass();
        }// w w  w .  ja  v  a 2s.co  m
        out.format("%n%n");
    }
}