当类不从任何父类继承时,为什么要使用super()

时间:2019-11-21 02:49:59

标签: java constructor super

我从我的讲师那里得到了一个视频商店的示例项目,该项目有3个类:VideoStore(包含主要功能),Video和Customer。我注意到在Customer类的构造函数中,我的讲师包括了super()方法,尽管该类本身并未从任何父类继承任何东西。

在这种情况下,谁能解释super()方法的使用?

public class Customer {
    private String name;
    private String address;
    private String ID;
    private String phone;
    private ArrayList<Video> rentals;


public Customer(String name, String address, String iD, String phone) {
        super();
        this.name = name;
        this.address = address;
        this.ID = iD;
        this.phone = phone;
        this.rentals = new ArrayList<Video>();
    }
...
}

0 个答案:

没有答案