Is super() used to call the parent constructor? Please explain super().

推荐答案

super() calls the parent constructor with no arguments.

It can be used also with arguments. I.e. super(argument1) and it will call the constructor that accepts 1 parameter of the type of argument1 (if exists).

Also it can be used to call methods from the parent. I.e. super.aMethod()

More info and tutorial here

Java相关问答推荐

如何在Spring Boot中创建500错误的响应正文?

在URL类图中表示Java swing类

try 使用Java 9或更高版本对特殊对象图进行解析时出现NullPointerException

Java WireMock定义存根在Cucumber并行执行的多线程测试中失败

屏蔽字母数字代码的Java正则表达式

为什么BasicComboBoxRenderer在文本不存在或文本为空的情况下设置两次文本?

我找不到&Quot;配置&的位置

我无法获取我的Java Spring应用程序的Logback跟踪日志(log)输出

计算两个浮点数之间的距离是否对称?

try 判断可选参数是否为空时出现空类型安全警告

GetChildren().emoveAll()不会删除 node

Spring安全令牌刷新和JWT签名与本地计算的签名不匹配

当我在Java中有一个Synchronized块来递增int时,必须声明一个变量Volatile吗?

没有Tomcat,IntelliJ如何在本地运行API?

Java嵌套流查找任意值

如何在Java中的重写方法参数中强制(Enum)接口实现?

谷歌应用引擎本地服务器赢得';t在eclipse上运行

使用DynamoDB增强客户端时未更新属性

Java ModbusRTU写寄存器

如何在Java中调用对象上预定义的接口方法列表?