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发行说明。
If you've never used an object-oriented programming language before, you'll need to learn a few basic concepts before you can begin writing any code.如果您以前从未使用过面向对象编程语言,那么在开始编写任何代码之前,您需要学习一些基本概念。This lesson will introduce you to objects, classes, inheritance, interfaces, and packages.本课程将向您介绍对象、类、继承、接口和包。Each discussion focuses on how these concepts relate to the real world, while simultaneously providing an introduction to the syntax of the Java programming language.每次讨论的重点都是这些概念与现实世界的关系,同时介绍Java编程语言的语法。
An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life.对象是相关状态和行为的软件包。软件对象通常用于对日常生活中的真实对象建模。This lesson explains how state and behavior are represented within an object, introduces the concept of data encapsulation, and explains the benefits of designing your software in this manner.本课程介绍如何在对象中表示状态和行为,介绍数据封装的概念,并说明以这种方式设计软件的好处。
A class is a blueprint or prototype from which objects are created.类是从中创建对象的蓝图或原型。This section defines a class that models the state and behavior of a real-world object.本节定义了一个类,该类对真实对象的状态和行为进行建模。It intentionally focuses on the basics, showing how even a simple class can cleanly model state and behavior.它有意地将重点放在基础上,展示了即使是一个简单的类如何清晰地建模状态和行为。
Inheritance provides a powerful and natural mechanism for organizing and structuring your software.继承为组织和构造软件提供了强大而自然的机制。This section explains how classes inherit state and behavior from their superclasses, and explains how to derive one class from another using the simple syntax provided by the Java programming language.本节解释类如何从其超类继承状态和行为,并解释如何使用Java编程语言提供的简单语法从一个类派生另一个类。
An interface is a contract between a class and the outside world.接口是类与外部世界之间的契约。When a class implements an interface, it promises to provide the behavior published by that interface.当类实现接口时,它承诺提供该接口发布的行为。This section defines a simple interface and explains the necessary changes for any class that implements it.本节定义了一个简单的接口,并解释了实现该接口的任何类的必要更改。
A package is a namespace for organizing classes and interfaces in a logical manner.包是以逻辑方式组织类和接口的命名空间。Placing your code into packages makes large software projects easier to manage.将代码放入包中可以使大型软件项目更易于管理。This section explains why this is useful, and introduces you to the Application Programming Interface (API) provided by the Java platform.本节解释了为什么这很有用,并向您介绍了Java平台提供的应用程序编程接口(API)。
Use the questions and exercises presented in this section to test your understanding of objects, classes, inheritance, interfaces, and packages.使用本节中介绍的问题和练习测试您对对象、类、继承、接口和包的理解。