反射常用方法
作者:互联网
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 { }
标签:反射,常用,getClass,interfaces,System,Class,Person,方法,class 来源: https://www.cnblogs.com/SSs1995/p/16158824.html