print Inheritance Tree - Java Reflection

Java examples for Reflection:Class

Description

print Inheritance Tree

Demo Code


//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");
    }
}

Related Tutorials