package 反射;
import java.lang.reflect.*;
import java.util.*;
public class Constuctor {
public static void main(String [] args) throws SecurityException, NoSuchMethodException {
Student s=new Student();
//输出结果为何是
//class2:反射.Student
//class1:反射.Student
}
}
class Person{
Person(){
System.out.println("class2:"+getClass().getName());//
}
}
class Student extends Person{
Student(){
//这一行默认调用super();
System.out.println("class1:"+super.getClass().getName());//super和this效果一样,why?
}
}
|