![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
反射
qq_33987908
这个作者很懒,什么都没留下…
展开
-
通过反射实例化某类的对象
直接使用默认构造器实例化对象: package test; import java.lang.reflect.InvocationTargetException; public class Test { public static void main(String[] args) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, No原创 2021-11-27 15:27:20 · 242 阅读 · 0 评论 -
3种获取某个类的Class对象的方法
1、通过调用某个对象的getClass()方法获取; package test; public class Test { public static void main(String[] args) { Test test = new Test(); Class<? extends Test> tClass = test.getClass(); System.out.println(tClass.getName()); } } 执行结果: test.Test 2、通过调用C原创 2021-11-27 15:05:43 · 581 阅读 · 0 评论