Java examples for Reflection:Interface
get Interfaces from Class
//package com.java2s; import java.util.ArrayList; import java.util.Arrays; public class Main { public static void main(String[] argv) throws Exception { Class clazz = String.class; System.out.println(java.util.Arrays.toString(getInterfaces(clazz))); }/*from ww w .j a v a 2 s . com*/ public static Class<?>[] getInterfaces(Class<?> clazz) { ArrayList<Class<?>> list = new ArrayList<Class<?>>(); while (clazz != null) { list.addAll(Arrays.asList(clazz.getInterfaces())); clazz = clazz.getSuperclass(); } return list.toArray(new Class[list.size()]); } }