public class ceshi9 { public staticvoid main(String[] args) { GoodStudenta3 = new GoodStudent("fwefew"); } } class Person { Person() { System.out.println("类Person构造方法一被调用"); } Person(Stringa) { System.out.println("类Preson构造方法二被调用"); } Person(Stringa,String b) { System.out.println("类Preson构造方法三被调用"); } } class Student extends Person { Student() { System.out.println("类Student构造方法一被调用"); } Student(Stringa) { System.out.println("类Student构造方法二被调用"); } Student(Stringa,String b) { System.out.println("类Student构造方法三被调用"); } } class GoodStudent extends Student { GoodStudent() { System.out.println("类GoodStudent构造方法一被调用"); } GoodStudent(Stringa) { System.out.println("类GoodStudent构造方法二被调用"); Studentaa = new Student("fwefewf","6534165"); Personbb = new Person("fsdfew"); } GoodStudent(Stringa,String b) { System.out.println("类GoodStudent构造方法三被调用"); } }
//为什么不能创建对象,然后 对象.方法 调用构造函数 如: //Person bb = new Person(); //bb.Person();
|