提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
获取接口包括超类
/** from * nowjava.com **/ //package com.nowjava; import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] argv) throws Exception { Class clazz = String.class; System.out.println(getInterfacesIncludeSuperClass(clazz)); } public static List<Class<?>> getInterfacesIncludeSuperClass( final Class<?> clazz) {//来自 时 代 J a v a 公 众 号 List<Class<?>> types = new ArrayList<Class<?>>(); for (Class<?> superClass = clazz; superClass != Object.class; superClass = superClass .getSuperclass()) { for (Class<?> intf : superClass.g