首页 > 其他 > 详细

11.断点追踪初始化过程

时间:2016-05-28 01:06:06      阅读:325      评论:0      收藏:0      [点我收藏+]
class Person {
    String name="李光";// 姓名
    public Person() {
        // super();//写不写该语句,效果一样
        System.out.println("execute Person()");
    }
    public Person(String name) {
        this.name = name;
        System.out.println("execute Person(name)");
    }
}

class Student extends Person {
    String school="武汉大学";// 学校
    public Student() {
        // super();//写不写该语句,效果一样
        System.out.println("execute Student() ");
    }
    public Student(String name, String school) {
        super(name); // 显示调用了父类有参构造方法,将不执行无参构造方法
        this.school = school;
        System.out.println("execute Student(name,school)");
    }
}

class PostGraduate extends Student {
    String guide;// 导师
    public PostGraduate() {
        // super();//写不写该语句,效果一样
        System.out.println("execute PostGraduate()");
    }
    public PostGraduate(String name, String school, String guide) {
        super(name, school);
        this.guide = guide;
        System.out.println("execute PostGraduate(name, school, guide)");
    }
}

class TestInherit {
    public static void main(String[] args) {
        PostGraduate pgdt=null;
        pgdt = new PostGraduate();
        System.out.println();
        pgdt=new PostGraduate("刘致同","北京大学","王老师");
    }
}

 

11.断点追踪初始化过程

原文:http://www.cnblogs.com/xiaotaoxu/p/5536449.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!