标签:stat print 反射 ati ring user dex one emc
记录是为了更好的成长!
public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException { //加载类的三种方式 //1、使用new关键字方法 User user = new User(); Method[] methods = user.getClass().getDeclaredMethods(); for(Method method:methods) { System.out.println(method); } //2、调用 Class.forName() 方法 Class clazz= Class.forName("com.boot.test.User"); Object user1 = clazz.newInstance(); Method[] methods1 = user1.getClass().getDeclaredMethods(); System.out.println(" Class.forName()+++++++++++++++++++++++++++++++"); for(Method method:methods1) { System.out.println(method); } //3、调用某个 ClassLoader 实例的 loadClass() 方法 Class clazz1 = ClassLoader.getSystemClassLoader().loadClass("com.boot.test.User"); Method[] methods2 = clazz1.getClass().getDeclaredMethods(); System.out.println(" loadClass()+++++++++++++++++++++++++++++++"); for(Method method:methods2) { System.out.println(method); } }
以上内容代表个人观点,仅供参考,不喜勿喷。。。
标签:stat print 反射 ati ring user dex one emc
原文地址:https://www.cnblogs.com/newbest/p/10054101.html