Class<test> testClass = test.class;//第一种
test test1 = new test();
Class<? extends test> aClass1 = test1.getClass();//第二种
try {
Class<?> aClass = Class.forName("test.java");//第三种(开发中最常用的,类的绝对路径可以通过配置文件获取)
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
创建反射对象的三种方法
最新推荐文章于 2022-12-25 20:00:47 发布

6477

被折叠的 条评论
为什么被折叠?



