The Java Tutorials have been written for JDK 8.Java教程是为JDK 8编写的。Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.本页中描述的示例和实践没有利用后续版本中引入的改进,并且可能使用不再可用的技术。See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.有关Java SE 9及其后续版本中更新的语言特性的摘要,请参阅Java语言更改。
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.有关所有JDK版本的新功能、增强功能以及已删除或不推荐的选项的信息,请参阅JDK发行说明。
Within a class, a field that has the same name as a field in the superclass hides the superclass's field, even if their types are different. 在类中,与超类中的字段同名的字段会隐藏超类的字段,即使它们的类型不同。Within the subclass, the field in the superclass cannot be referenced by its simple name. 在子类中,超类中的字段不能由其简单名称引用。Instead, the field must be accessed through 相反,必须通过super
, which is covered in the next section. super
访问该字段,这将在下一节中介绍。Generally speaking, we don't recommend hiding fields as it makes code difficult to read.一般来说,我们不建议隐藏字段,因为它会使代码难以阅读。