获取所有接口为数组
import java.lang.reflect.Array; import java.lang.reflect.Constructor; /** 来 自 时 代 Java 公 众 号 - nowjava.com **/ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.URL; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; public class Main{ public static void main(String[] argv) throws Exception{ Class clazz = String.class; System.out.println(java.util.Arrays.toString(getAllInterfacesAsArray(clazz))); } public static Class<?>[] getAllInterfacesAsArray(Class<?> clazz) { if (clazz == null) { return null; /** 来 自 时代Java **/ } List<Class<?>> interfacesFound = CollectionUtil.createArrayList(); getAllInterfaces(clazz, interfacesFound); return interfacesFound.toArray(new Class<?>[0]); } public static List<Class<?>> getAllInterfaces(Class<?> clazz) { if (clazz == null) { return null; } List<Class<?>> interfacesFound = CollectionUtil.createArrayList(); getAllInterfaces(clazz, interfacesFound); return interfacesFound; } private static void getAllInterfaces(Class<?> clazz, List<Class<?>> interfacesFound) { while (clazz != null) { Class<?>[] in