package com.itheima.myreffect2;
public class Reffcdtdemo1 {
public static void main(String[] args) throws ClassNotFoundException {
Class<?> aClass = Class.forName("com.itheima.myreffect2.Student");
System.out.println(aClass);
Class<Student> studentClass = Student.class;
System.out.println(studentClass);
Student s=new Student();
Class<? extends Student> aClass1 = s.getClass();
System.out.println(aClass1);
System.out.println(aClass==studentClass);
}
}
package com.itheima.myreffect2;
public class Student {
private String name;
private int age;
public void study(){
System.out.println("学生在学习");
}
@Override
public String toString() {
return "Student{" +
"name='" + name + '\'' +
", age=" + age +
'}';
}
}
|