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

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

问题描述

用于调用父构造函数的 super()
请解释 super()

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

推荐答案

super()调用没有参数的父构造函数。

super() calls the parent constructor with no arguments.

它也可以用于参数。即 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).

此外,它还可用于从父级调用方法。即 super.aMethod()

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

更多信息和教程这里

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

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