Java 中的 super() [英] super() in Java

查看:26
本文介绍了Java 中的 super()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

super() 是用来调用父构造函数的吗?请解释super().

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

推荐答案

super() 不带参数调用父构造函数.

super() calls the parent constructor with no arguments.

它也可以与参数一起使用.IE.super(argument1) 它将调用接受 argument1 类型的 1 个参数的构造函数(如果存在).

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).

它还可以用于从父级调用方法.IE.super.aMethod()

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

更多信息和教程这里

这篇关于Java 中的 super()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆