什么是java中的构造函数,如果它不是类的成员? [英] What is constructor in java, if it is not a member of class?

查看:161
本文介绍了什么是java中的构造函数,如果它不是类的成员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们称之为构造函数,如果它不是Oracle doc中所述的类的成员: http://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html

What do we we call a constructor, if it is not a member of a class as stated in Oracle doc: http://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html

推荐答案

我认为术语成员被定义为排除构造函数为了方便。构造器,甚至公共的,不被继承;成员是继承的(除非它们是静态的和/或私有的)。在谈论继承规则时总是不得不说除了构造函数之外的成员这将是尴尬的。

I think the term "member" was defined to exclude constructors for the sake of convenience. Constructors, even public ones, are not inherited; members are inherited (unless they are static and/or private). It would be awkward when talking about the rules of inheritance to always have to say "members except constructors".

Java语言规范,§8.2


构造函数,静态初始化器和实例初始化器不是成员,因此不会继承。

Constructors, static initializers, and instance initializers are not members and therefore are not inherited.

只需调用构造函数构造函数。

Just call constructors "constructors".

这篇关于什么是java中的构造函数,如果它不是类的成员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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