反射常用方法
public class a { public static void main(String[] args) { Person person = new Person(); //getClass():取得当前对象所属的Class对象 Class<? extends Person> aClass = person.getClass(); //反射获取类加载器 ClassLoader classLoader = Person.class.getClassLoader(); //获取类实现的接口数组 Class<?>[] interfaces = Person.class.getInterfaces(); for (Class<?> anInterface : interfaces) { System.out.println(anInterface); } // System.out.println(interfaces); } } class Person implements Sport { }