获取反射机制三种方式

    获取反射机制三种方式对象

// 一、经过创建对象
Student student = new Student();
System.out.println(student.getClass().getName());
System.out.println("-------------------------");

// 二、经过类相对路径
Class<?> aClass = Class.forName("com.study.hll.demo.Student");
System.out.println(aClass.getName());
System.out.println("-------------------------");

// 三、经过类名
Class<Student> studentClass = Student.class;
System.out.println(studentClass.getName());
相关文章
相关标签/搜索