Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java中调用继承构造函数的构造函数_Java_Class_Inheritance_Constructor_Super - Fatal编程技术网

java中调用继承构造函数的构造函数

java中调用继承构造函数的构造函数,java,class,inheritance,constructor,super,Java,Class,Inheritance,Constructor,Super,我将如何在java中实现这一点 我需要子类中的构造函数来调用超类中继承的构造函数。我需要使用一种特殊的语法来实现这一点吗 我使用扩展从Person类继承。如何使用super() 这是我的班级: public class Student extends Person { protected int id; public Student() { // how do i call the inherited constructor here? } } super(a

我将如何在java中实现这一点

我需要子类中的构造函数来调用超类中继承的构造函数。我需要使用一种特殊的语法来实现这一点吗

我使用扩展从Person类继承。如何使用super()

这是我的班级:

public class Student extends Person
{
   protected int id;

   public Student()
   {
   // how do i call the inherited constructor here?
   }

}
super(arg1、arg2等)

在任何未显式调用的构造函数的开头都有一个对
super()
(无参数)的隐式调用。

super(arg1、arg2等)


在任何未显式调用的构造函数的开头,都有一个对
super()
(无参数)的隐式调用。

与此完全相同:
super()
。但是我假设您需要调用带有参数的方法,因为存在对
super()
的隐式调用。添加参数,如下所示:
super(arg0、arg1、arg2等)

完全一样:
super()
。但是我假设您需要调用带有参数的方法,因为存在对
super()
的隐式调用。添加参数,如下所示:
super(arg0、arg1、arg2等)