The Java® Language Specification

Java SE 17 Edition

James Gosling

Bill Joy

Guy Steele

Gilad Bracha

Alex Buckley

Daniel Smith

Gavin Bierman

2021-08-09

Legal Notice

Table of Contents目录

1. Introduction介绍
1.1. Organization of the Specification规范的组织
1.2. Example Programs示例程序
1.3. Notation记号法
1.4. Relationship to Predefined Classes and Interfaces与预定义类和接口的关系
1.5. Preview Features预览功能
1.6. Feedback反馈
1.7. References参考资料
2. Grammars语法
2.1. Context-Free Grammars上下文无关文法
2.2. The Lexical Grammar词汇语法
2.3. The Syntactic Grammar句法语法
2.4. Grammar Notation语法符号
3. Lexical Structure词法结构
3.1. Unicode
3.2. Lexical Translations词汇翻译
3.3. Unicode EscapesUnicode转义
3.4. Line Terminators行终止
3.5. Input Elements and Tokens输入元素和标记
3.6. White Space空白
3.7. Comments注释
3.8. Identifiers标识符
3.9. Keywords关键词
3.10. Literals字面值
3.10.1. Integer Literals整数字面值
3.10.2. Floating-Point Literals浮点字面值
3.10.3. Boolean Literals布尔型字面值
3.10.4. Character Literals字符字面值
3.10.5. String Literals字符串字面值
3.10.6. Text Blocks文本块
3.10.7. Escape Sequences转义序列
3.10.8. The Null LiteralNull字面值
3.11. Separators分隔符
3.12. Operators运算符
4. Types, Values, and Variables类型、值和变量
4.1. The Kinds of Types and Values类型和值的种类
4.2. Primitive Types and Values基本类型和值
4.2.1. Integral Types and Values积分类型和积分值
4.2.2. Integer Operations整数运算
4.2.3. Floating-Point Types and Values浮点类型和值
4.2.4. Floating-Point Operations浮点运算
4.2.5. The boolean Type and boolean Valuesboolean类型和布尔值
4.3. Reference Types and Values引用类型和值
4.3.1. Objects物体
4.3.2. The Class ObjectObject
4.3.3. The Class StringString
4.3.4. When Reference Types Are the Same当引用类型相同时
4.4. Type Variables类型变量
4.5. Parameterized Types参数化类型
4.5.1. Type Arguments of Parameterized Types参数化类型的类型参数
4.5.2. Members and Constructors of Parameterized Types参数化类型的成员和构造函数
4.6. Type Erasure类型擦除
4.7. Reifiable Types可偿还类型
4.8. Raw Types原始类型
4.9. Intersection Types交集类型
4.10. Subtyping子类型
4.10.1. Subtyping among Primitive Types基元类型间的子类型划分
4.10.2. Subtyping among Class and Interface Types类和接口类型之间的子类型
4.10.3. Subtyping among Array Types数组类型之间的子类型
4.10.4. Least Upper Bound最小上界
4.10.5. Type Projections类型投影
4.11. Where Types Are Used使用类型的位置
4.12. Variables变量
4.12.1. Variables of Primitive Type基元类型的变量
4.12.2. Variables of Reference Type引用类型的变量
4.12.3. Kinds of Variables变量种类
4.12.4. final Variables变量
4.12.5. Initial Values of Variables变量的初始值
4.12.6. Types, Classes, and Interfaces类型、类和接口
5. Conversions and Contexts转换和上下文
5.1. Kinds of Conversion转换类型
5.1.1. Identity Conversion身份转换
5.1.2. Widening Primitive Conversion扩大原语转换
5.1.3. Narrowing Primitive Conversion基本类型转换
5.1.4. Widening and Narrowing Primitive Conversion扩大和缩小原语转换
5.1.5. Widening Reference Conversion加宽参考转换
5.1.6. Narrowing Reference Conversion缩小参考转换
5.1.6.1. Allowed Narrowing Reference Conversion允许的缩小引用转换
5.1.6.2. Checked and Unchecked Narrowing Reference Conversions选中和未选中缩小引用转换
5.1.6.3. Narrowing Reference Conversions at Run Time在运行时缩小引用转换
5.1.7. Boxing Conversion装箱转换
5.1.8. Unboxing Conversion拆箱转换
5.1.9. Unchecked Conversion未经检查的转换
5.1.10. Capture Conversion捕获转换
5.1.11. String Conversion字符串转换
5.1.12. Forbidden Conversions禁止转换
5.2. Assignment Contexts分配上下文
5.3. Invocation Contexts调用上下文
5.4. String Contexts字符串上下文
5.5. Casting Contexts强制转换上下文
5.6. Numeric Contexts数字上下文
6. Names命名
6.1. Declarations声明
6.2. Names and Identifiers名称和标识符
6.3. Scope of a Declaration声明的范围
6.3.1. Scope for Pattern Variables in Expressions表达式中模式变量的作用域
6.3.1.1. Conditional-And Operator条件与运算符 &&
6.3.1.2. Conditional-Or Operator条件或运算符 ||
6.3.1.3. Logical Complement Operator逻辑补码运算符 !
6.3.1.4. Conditional Operator条件运算符 ? :
6.3.1.5. Pattern Match Operator模式匹配运算符 instanceof
6.3.1.6. switch Expressions
6.3.1.7. Parenthesized Expressions括号表达式
6.3.2. Scope for Pattern Variables in Statements语句中模式变量的作用域
6.3.2.1. Blocks
6.3.2.2. if Statements语句
6.3.2.3. while Statements语句
6.3.2.4. do Statements语句
6.3.2.5. for Statements语句
6.3.2.6. switch Statements语句
6.3.2.7. Labeled Statements标记语句
6.4. Shadowing and Obscuring遮蔽
6.4.1. Shadowing阴影
6.4.2. Obscuring遮蔽
6.5. Determining the Meaning of a Name确定名称的含义
6.5.1. Syntactic Classification of a Name According to Context根据上下文对名称进行句法分类
6.5.2. Reclassification of Contextually Ambiguous Names上下文歧义名称的重新分类
6.5.3. Meaning of Module Names and Package Names模块名称和包名称的含义
6.5.3.1. Simple Package Names简单包名
6.5.3.2. Qualified Package Names限定包名
6.5.4. Meaning of PackageOrTypeNames的含义
6.5.4.1. Simple简单的 PackageOrTypeNames
6.5.4.2. Qualified限定的 PackageOrTypeNames
6.5.5. Meaning of Type Names类型名称的含义
6.5.5.1. Simple Type Names简单类型名称
6.5.5.2. Qualified Type Names限定类型名
6.5.6. Meaning of Expression Names表达名称的含义
6.5.6.1. Simple Expression Names简单表达式名称
6.5.6.2. Qualified Expression Names限定表达式名
6.5.7. Meaning of Method Names方法名称的含义
6.5.7.1. Simple Method Names简单方法名
6.6. Access Control访问控制
6.6.1. Determining Accessibility确定可访问性
6.6.2. Details on protected Accessprotected访问的详情
6.6.2.1. Access to a protected Member访问protected成员
6.6.2.2. Access to a protected Constructor访问protected构造函数
6.7. Fully Qualified Names and Canonical Names完全限定名和规范名
7. Packages and Modules软件包和模块
7.1. Package Members一揽子成员
7.2. Host Support for Modules and Packages对模块和包的主机支持
7.3. Compilation Units编辑单位
7.4. Package Declarations包声明
7.4.1. Named Packages命名包
7.4.2. Unnamed Packages未命名的包
7.4.3. Package Observability and Visibility包的可观测性和可见性
7.5. Import Declarations导入声明
7.5.1. Single-Type-Import Declarations单一类型导入声明
7.5.2. Type-Import-on-Demand Declarations输入按需导入声明
7.5.3. Single-Static-Import Declarations单一静态导入声明
7.5.4. Static-Import-on-Demand Declarations按需静态导入声明
7.6. Top Level Class and Interface Declarations顶级类和接口声明
7.7. Module Declarations模块声明
7.7.1. Dependences依赖
7.7.2. Exported and Opened Packages导出和打开的包
7.7.3. Service Consumption服务消费
7.7.4. Service Provision服务提供
7.7.5. Unnamed Modules未命名模块
7.7.6. Observability of a Module模的可观测性
8. Classes
8.1. Class Declarations类声明
8.1.1. Class Modifiers类修饰符
8.1.1.1. abstract Classes
8.1.1.2. sealed, non-sealed, and final Classessealed类、non-sealed类和final
8.1.1.3. strictfp Classes
8.1.1.4. static Classes
8.1.2. Generic Classes and Type Parameters泛型类和类型参数
8.1.3. Inner Classes and Enclosing Instances内部类和封闭实例
8.1.4. Superclasses and Subclasses超类和子类
8.1.5. Superinterfaces超接口
8.1.6. Permitted Direct Subclasses允许的直接子类
8.1.7. Class Body and Member Declarations类体和成员声明
8.2. Class Members类成员
8.3. Field Declarations字段声明
8.3.1. Field Modifiers字段修饰符
8.3.1.1. static Fields字段
8.3.1.2. final Fields字段
8.3.1.3. transient Fields字段
8.3.1.4. volatile Fields字段
8.3.2. Field Initialization字段初始化
8.3.3. Restrictions on Field References in Initializers初始值设定项中字段引用的限制
8.4. Method Declarations方法声明
8.4.1. Formal Parameters形式参数
8.4.2. Method Signature方法签名
8.4.3. Method Modifiers方法修饰符
8.4.3.1. abstract Methods方法
8.4.3.2. static Methods方法
8.4.3.3. final Methods方法
8.4.3.4. native Methods方法
8.4.3.5. strictfp Methods方法
8.4.3.6. synchronized Methods方法
8.4.4. Generic Methods通用方法
8.4.5. Method Result方法结果
8.4.6. Method Throws方法抛出
8.4.7. Method Body方法体
8.4.8. Inheritance, Overriding, and Hiding继承、重写和隐藏
8.4.8.1. Overriding (by Instance Methods)重写(按实例方法)
8.4.8.2. Hiding (by Class Methods)隐藏(通过类方法)
8.4.8.3. Requirements in Overriding and Hiding覆盖和隐藏中的需求
8.4.8.4. Inheriting Methods with Override-Equivalent Signatures使用重写等效签名继承方法
8.4.9. Overloading重载
8.5. Member Class and Interface Declarations成员类和接口声明
8.6. Instance Initializers实例初始值设定项
8.7. Static Initializers静态初始化器
8.8. Constructor Declarations构造函数声明
8.8.1. Formal Parameters形式参数
8.8.2. Constructor Signature构造函数签名
8.8.3. Constructor Modifiers构造函数修饰符
8.8.4. Generic Constructors泛型构造函数
8.8.5. Constructor Throws构造函数抛出
8.8.6. The Type of a Constructor构造函数的类型
8.8.7. Constructor Body构造函数体
8.8.7.1. Explicit Constructor Invocations显式构造函数调用
8.8.8. Constructor Overloading构造函数重载
8.8.9. Default Constructor缺省构造
8.8.10. Preventing Instantiation of a Class防止类的实例化
8.9. Enum Classes枚举类
8.9.1. Enum Constants枚举常数
8.9.2. Enum Body Declarations枚举体声明
8.9.3. Enum Members枚举成员
8.10. Record Classes记录类
8.10.1. Record Components记录组件
8.10.2. Record Body Declarations记录机构声明
8.10.3. Record Members记录成员
8.10.4. Record Constructor Declarations记录构造函数声明
8.10.4.1. Normal Canonical Constructors正规正则构造函数
8.10.4.2. Compact Canonical Constructors紧正则构造函数
9. Interfaces接口
9.1. Interface Declarations接口声明
9.1.1. Interface Modifiers接口修饰符
9.1.1.1. abstract Interfaces接口
9.1.1.2. strictfp Interfaces接口
9.1.1.3. static Interfaces接口
9.1.1.4. sealed and non-sealed Interfacessealed接口和non-sealed接口
9.1.2. Generic Interfaces and Type Parameters泛型接口和类型参数
9.1.3. Superinterfaces and Subinterfaces超级接口和子接口
9.1.4. Permitted Direct Subclasses and Subinterfaces允许的直接子类和子接口
9.1.5. Interface Body and Member Declarations接口体和成员声明
9.2. Interface Members接口成员
9.3. Field (Constant) Declarations字段(常量)声明
9.3.1. Initialization of Fields in Interfaces接口中字段的初始化
9.4. Method Declarations方法声明
9.4.1. Inheritance and Overriding继承和重写
9.4.1.1. Overriding (by Instance Methods)重写(按实例方法)
9.4.1.2. Requirements in Overriding压倒一切的要求
9.4.1.3. Inheriting Methods with Override-Equivalent Signatures使用重写等效签名继承方法
9.4.2. Overloading超载
9.4.3. Interface Method Body接口方法体
9.5. Member Class and Interface Declarations成员类和接口声明
9.6. Annotation Interfaces批注接口
9.6.1. Annotation Interface Elements批注接口元素
9.6.2. Defaults for Annotation Interface Elements批注接口元素的默认值
9.6.3. Repeatable Annotation Interfaces可重复批注接口
9.6.4. Predefined Annotation Interfaces预定义的批注接口
9.6.4.1. @Target
9.6.4.2. @Retention
9.6.4.3. @Inherited
9.6.4.4. @Override
9.6.4.5. @SuppressWarnings
9.6.4.6. @Deprecated
9.6.4.7. @SafeVarargs
9.6.4.8. @Repeatable
9.6.4.9. @FunctionalInterface
9.7. Annotations批注
9.7.1. Normal Annotations正常批注
9.7.2. Marker Annotations标记批注
9.7.3. Single-Element Annotations单元素批注
9.7.4. Where Annotations May Appear批注可能出现的位置
9.7.5. Multiple Annotations of the Same Interface同一接口的多个批注
9.8. Functional Interfaces功能接口
9.9. Function Types功能类型
10. Arrays数组
10.1. Array Types数组类型
10.2. Array Variables数组变量
10.3. Array Creation数组创建
10.4. Array Access阵列访问
10.5. Array Store Exception数组存储异常
10.6. Array Initializers数组初始值设定项
10.7. Array Members数组成员
10.8. Class Objects for Arrays数组的Class对象
10.9. An Array of Characters Is Not a String字符数组不是String
11. Exceptions异常
11.1. The Kinds and Causes of Exceptions异常的种类和原因
11.1.1. The Kinds of Exceptions例外情况的种类
11.1.2. The Causes of Exceptions例外的原因
11.1.3. Asynchronous Exceptions异步异常
11.2. Compile-Time Checking of Exceptions异常的编译时检查
11.2.1. Exception Analysis of Expressions表达式的异常分析
11.2.2. Exception Analysis of Statements语句的异常分析
11.2.3. Exception Checking异常检查
11.3. Run-Time Handling of an Exception异常的运行时处理
12. Execution执行
12.1. Java Virtual Machine StartupJava虚拟机启动
12.1.1. Load the Class 加载类Test
12.1.2. Link Test: Verify, Prepare, (Optionally) Resolve链接Test:验证、准备(可选)解决
12.1.3. Initialize Test: Execute Initializers初始化测试:执行初始化器
12.1.4. Invoke 调用Test.main
12.2. Loading of Classes and Interfaces类和接口的加载
12.2.1. The Loading Process加载过程
12.2.2. Class Loader Consistency类加载器一致性
12.3. Linking of Classes and Interfaces类与接口的链接
12.3.1. Verification of the Binary Representation二进制表示的验证
12.3.2. Preparation of a Class or Interface类或接口的准备
12.3.3. Resolution of Symbolic References符号引用的解析
12.4. Initialization of Classes and Interfaces类和接口的初始化
12.4.1. When Initialization Occurs初始化发生时
12.4.2. Detailed Initialization Procedure详细的初始化过程
12.5. Creation of New Class Instances创建新的类实例
12.6. Finalization of Class Instances类实例的终结
12.6.1. Implementing Finalization实施定稿
12.6.2. Interaction with the Memory Model与记忆模型的交互作用
12.7. Unloading of Classes and Interfaces类和接口的卸载
12.8. Program Exit程序退出
13. Binary Compatibility二进制兼容性
13.1. The Form of a Binary二进制的形式
13.2. What Binary Compatibility Is and Is Not二进制兼容性是什么、不是什么
13.3. Evolution of Packages and Modules包和模块的演变
13.4. Evolution of Classes类的演变
13.4.1. abstract Classes
13.4.2. sealed, non-sealed, and final Classessealed类、non-sealed类和final
13.4.2.1. sealed Classes
13.4.2.2. non-sealed Classes
13.4.2.3. final Classes
13.4.3. public Classes
13.4.4. Superclasses and Superinterfaces超类与超接口
13.4.5. Class Type Parameters类类型参数
13.4.6. Class Body and Member Declarations类主体和成员声明
13.4.7. Access to Members and Constructors访问成员和构造函数
13.4.8. Field Declarations字段声明
13.4.9. final Fields and static Constant Variablesfinal字段和static常量变量
13.4.10. static Fields字段
13.4.11. transient Fields字段
13.4.12. Method and Constructor Declarations方法和构造函数声明
13.4.13. Method and Constructor Type Parameters方法和构造函数类型参数
13.4.14. Method and Constructor Formal Parameters方法和构造函数形式参数
13.4.15. Method Result Type方法结果类型
13.4.16. abstract Methods方法
13.4.17. final Methods方法
13.4.18. native Methods方法
13.4.19. static Methods方法
13.4.20. synchronized Methods方法
13.4.21. Method and Constructor Throws方法和构造函数抛出
13.4.22. Method and Constructor Body方法和构造函数体
13.4.23. Method and Constructor Overloading方法和构造函数重载
13.4.24. Method Overriding方法重写
13.4.25. Static Initializers静态初始化器
13.4.26. Evolution of Enum Classes枚举类的演化
13.4.27. Evolution of Record Classes记录类别的演变
13.5. Evolution of Interfaces界面的演变
13.5.1. public Interfaces接口
13.5.2. sealed and non-sealed Interfacessealed接口和non-sealed接口
13.5.3. Superinterfaces超接口
13.5.4. Interface Members接口成员
13.5.5. Interface Type Parameters接口类型参数
13.5.6. Field Declarations字段声明
13.5.7. Interface Method Declarations接口方法声明
13.5.8. Annotation Interfaces批注接口
14. Blocks, Statements, and Patterns块、语句和模式
14.1. Normal and Abrupt Completion of Statements语句的正常和突然完成
14.2. Blocks
14.3. Local Class and Interface Declarations本地类和接口声明
14.4. Local Variable Declarations局部变量声明
14.4.1. Local Variable Declarators and Types局部变量声明器和类型
14.4.2. Local Variable Declaration Statements局部变量声明语句
14.5. Statements语句
14.6. The Empty Statement空语句
14.7. Labeled Statements标记语句
14.8. Expression Statements表达式语句
14.9. The if Statementif语句
14.9.1. The if-then Statementif-then语句
14.9.2. The if-then-else Statementif-then-else语句
14.10. The assert Statementassert语句
14.11. The switch Statementswitch语句
14.11.1. Switch Blocks交换块
14.11.2. The Switch Block of a switch Statementswitch语句的交换块
14.11.3. Execution of a switch Statementswitch语句的执行
14.12. The while Statementwhile语句
14.12.1. Abrupt Completion of while Statementwhile语句的突然完成
14.13. The do Statementdo语句
14.13.1. Abrupt Completion of do Statementdo语句的突然完成
14.14. The for Statementfor语句
14.14.1. The basic for Statementfor语句
14.14.1.1. Initialization of for Statementfor语句的初始化
14.14.1.2. Iteration of for Statementfor语句的迭代
14.14.1.3. Abrupt Completion of for Statementfor语句的突然完成
14.14.2. The enhanced for statement增强的for语句
14.15. The break Statementbreak语句
14.16. The continue Statementcontinue语句
14.17. The return Statementreturn语句
14.18. The throw Statementthrow语句
14.19. The synchronized Statementsynchronized语句
14.20. The try statementtry语句
14.20.1. Execution of try-catchtry-catch的执行
14.20.2. Execution of try-finally and try-catch-finallytry-finallytry-catch-finally的执行
14.20.3. try-with-resources
14.20.3.1. Basic 基本的try-with-resources
14.20.3.2. Extended 扩展的try-with-resources
14.21. The yield Statementyield语句
14.22. Unreachable Statements无法到达的语句
14.30. Patterns模式
14.30.1. Kinds of Patterns模式的种类
14.30.2. Pattern Matching模式匹配
15. Expressions表达
15.1. Evaluation, Denotation, and Result评估、表示和结果
15.2. Forms of Expressions表达形式
15.3. Type of an Expression表达式类型
15.4. Floating-point Expressions浮点表达式
15.5. Expressions and Run-Time Checks表达式和运行时检查
15.6. Normal and Abrupt Completion of Evaluation正常和突然完成评估
15.7. Evaluation Order评估顺序
15.7.1. Evaluate Left-Hand Operand First首先计算左手操作数
15.7.2. Evaluate Operands before Operation运算前计算操作数
15.7.3. Evaluation Respects Parentheses and Precedence求值尊重括号和优先级
15.7.4. Argument Lists are Evaluated Left-to-Right参数列表从左到右求值
15.7.5. Evaluation Order for Other Expressions其他表达式的求值顺序
15.8. Primary Expressions主要表达
15.8.1. Lexical Literals词汇字面量
15.8.2. Class Literals类字面量
15.8.3. this
15.8.4. Qualified 限定的this
15.8.5. Parenthesized Expressions括号表达式
15.9. Class Instance Creation Expressions类实例创建表达式
15.9.1. Determining the Class being Instantiated确定正在实例化的类
15.9.2. Determining Enclosing Instances确定封闭实例
15.9.3. Choosing the Constructor and its Arguments选择构造函数及其参数
15.9.4. Run-Time Evaluation of Class Instance Creation Expressions类实例创建表达式的运行时计算
15.9.5. Anonymous Class Declarations匿名类声明
15.9.5.1. Anonymous Constructors匿名构造函数
15.10. Array Creation and Access Expressions数组创建和访问表达式
15.10.1. Array Creation Expressions数组创建表达式
15.10.2. Run-Time Evaluation of Array Creation Expressions数组创建表达式的运行时计算
15.10.3. Array Access Expressions数组访问表达式
15.10.4. Run-Time Evaluation of Array Access Expressions数组访问表达式的运行时计算
15.11. Field Access Expressions字段访问表达式
15.11.1. Field Access Using a Primary使用主服务器进行字段访问
15.11.2. Accessing Superclass Members using super使用super访问超类成员
15.12. Method Invocation Expressions方法调用表达式
15.12.1. Compile-Time Step 1: Determine Type to Search编译时步骤1:确定要搜索的类型
15.12.2. Compile-Time Step 2: Determine Method Signature编译时步骤2:确定方法签名
15.12.2.1. Identify Potentially Applicable Methods确定可能适用的方法
15.12.2.2. Phase 1: Identify Matching Arity Methods Applicable by Strict Invocation阶段1:识别通过严格调用适用的匹配Arity方法
15.12.2.3. Phase 2: Identify Matching Arity Methods Applicable by Loose Invocation阶段2:确定松散调用适用的匹配Arity方法
15.12.2.4. Phase 3: Identify Methods Applicable by Variable Arity Invocation阶段3:确定变量Arity调用适用的方法
15.12.2.5. Choosing the Most Specific Method选择最具体的方法
15.12.2.6. Method Invocation Type方法调用类型
15.12.3. Compile-Time Step 3: Is the Chosen Method Appropriate?编译时步骤3:选择的方法合适吗?
15.12.4. Run-Time Evaluation of Method Invocation方法调用的运行时评估
15.12.4.1. Compute Target Reference (If Necessary)计算目标参考(如有必要)
15.12.4.2. Evaluate Arguments评估参数
15.12.4.3. Check Accessibility of Type and Method检查类型和方法的可访问性
15.12.4.4. Locate Method to Invoke查找要调用的方法
15.12.4.5. Create Frame, Synchronize, Transfer Control创建帧、同步、传输控制
15.13. Method Reference Expressions方法引用表达式
15.13.1. Compile-Time Declaration of a Method Reference方法引用的编译时声明
15.13.2. Type of a Method Reference方法引用的类型
15.13.3. Run-Time Evaluation of Method References方法引用的运行时评估
15.14. Postfix Expressions后缀表达式
15.14.1. Expression Names表达式名称
15.14.2. Postfix Increment Operator 后缀增量运算符++
15.14.3. Postfix Decrement Operator 后缀减量运算符--
15.15. Unary Operators单目运算符
15.15.1. Prefix Increment Operator 前缀增量运算符++
15.15.2. Prefix Decrement Operator 前缀减量运算符--
15.15.3. Unary Plus Operator 一元加号运算符+
15.15.4. Unary Minus Operator 一元负运算符-
15.15.5. Bitwise Complement Operator 位补运算符~
15.15.6. Logical Complement Operator 逻辑补码运算符!
15.16. Cast Expressions演员表情
15.17. Multiplicative Operators乘法运算符
15.17.1. Multiplication Operator 乘法运算符*
15.17.2. Division Operator 除法运算符/
15.17.3. Remainder Operator 余数运算符%
15.18. Additive Operators加法运算符
15.18.1. String Concatenation Operator 字符串连接运算符+
15.18.2. Additive Operators (+ and -) for Numeric Types用于数字类型的加法运算符(+-
15.19. Shift Operators位移运算符
15.20. Relational Operators关系运算符
15.20.1. Numerical Comparison Operators <, <=, >, and >=数值比较运算符<<=>>=
15.20.2. The instanceof Operatorinstanceof运算符
15.21. Equality Operators相等运算符
15.21.1. Numerical Equality Operators == and !=数值相等运算符==!=
15.21.2. Boolean Equality Operators == and !=布尔等式运算符==!=
15.21.3. Reference Equality Operators == and !=引用相等运算符==!=
15.22. Bitwise and Logical Operators位运算符和逻辑运算符
15.22.1. Integer Bitwise Operators &, ^, and |整数位运算符&^|
15.22.2. Boolean Logical Operators 布尔逻辑运算符&, ^, and |
15.23. Conditional-And Operator 条件与运算符&&
15.24. Conditional-Or Operator 条件或运算符||
15.25. Conditional Operator 条件运算符? :
15.25.1. Boolean Conditional Expressions布尔条件表达式
15.25.2. Numeric Conditional Expressions数值条件表达式
15.25.3. Reference Conditional Expressions引用条件表达式
15.26. Assignment Operators赋值运算符
15.26.1. Simple Assignment Operator 简单赋值运算符=
15.26.2. Compound Assignment Operators复合赋值运算符
15.27. Lambda Expressions表达式
15.27.1. Lambda ParametersLambda参数
15.27.2. Lambda BodyLambda体
15.27.3. Type of a Lambda ExpressionLambda表达式的类型
15.27.4. Run-Time Evaluation of Lambda ExpressionsLambda表达式的运行时计算
15.28. switch Expressions表达
15.28.1. The Switch Block of a switch Expressionswitch表达式的交换块
15.28.2. Run-Time Evaluation of switch Expressionsswitch表达式的运行时计算
15.29. Constant Expressions恒定表达式
16. Definite Assignment明确分配
16.1. Definite Assignment and Expressions定赋值与表达式
16.1.1. Boolean Constant Expressions布尔常量表达式
16.1.2. Conditional-And Operator 条件与运算符&&
16.1.3. Conditional-Or Operator 条件或运算符||
16.1.4. Logical Complement Operator 逻辑补码运算符!
16.1.5. Conditional Operator 条件运算符? :
16.1.6. switch Expressions表达式
16.1.7. Other Expressions of Type booleanboolean型的其他表达式
16.1.8. Assignment Expressions赋值表达式
16.1.9. Operators ++ and --运算符++--
16.1.10. Other Expressions其他表达式
16.2. Definite Assignment and Statements定赋值与语句
16.2.1. Empty Statements空语句
16.2.2. Blocks
16.2.3. Local Class and Interface Declarations本地类和接口声明
16.2.4. Local Variable Declaration Statements局部变量声明语句
16.2.5. Labeled Statements标记语句
16.2.6. Expression Statements表达式语句
16.2.7. if Statements语句
16.2.8. assert Statements语句
16.2.9. switch Statements语句
16.2.10. while Statements语句
16.2.11. do Statements语句
16.2.12. for Statements语句
16.2.12.1. Initialization Part of for Statementfor语句的初始化部分
16.2.12.2. Incrementation Part of for Statementfor语句的增量部分
16.2.13. break, yield, continue, return, and throw Statementsbreak语句、yield语句、continue语句和return语句
16.2.14. synchronized Statements语句
16.2.15. try Statements语句
16.3. Definite Assignment and Parameters定赋值与参数
16.4. Definite Assignment and Array Initializers定赋值和数组初始值设定项
16.5. Definite Assignment and Enum Constants定赋值和枚举常量
16.6. Definite Assignment and Anonymous Classes定赋值与匿名类
16.7. Definite Assignment and Member Classes and Interfaces确定赋值和成员类及接口
16.8. Definite Assignment and Static Initializers定赋值和静态初始值设定项
16.9. Definite Assignment, Constructors, and Instance Initializers确定赋值、构造函数和实例初始值设定项
17. Threads and Locks线程和锁
17.1. Synchronization同步
17.2. Wait Sets and Notification等待集和通知
17.2.1. Wait等待
17.2.2. Notification通知
17.2.3. Interruptions打断
17.2.4. Interactions of Waits, Notification, and Interruption等待、通知和中断的交互
17.3. Sleep and Yield睡眠与产生
17.4. Memory Model记忆模型
17.4.1. Shared Variables共享变量
17.4.2. Actions操作
17.4.3. Programs and Program Order程序和程序顺序
17.4.4. Synchronization Order同步顺序
17.4.5. Happens-before Order发生在命令之前
17.4.6. Executions执行
17.4.7. Well-Formed Executions形式合理的执行
17.4.8. Executions and Causality Requirements执行和因果关系要求
17.4.9. Observable Behavior and Nonterminating Executions可观察行为和非终止执行
17.5. final Field Semantics字段语义
17.5.1. Semantics of final Fieldsfinal字段的语义
17.5.2. Reading final Fields During Construction在构造期间读取final字段
17.5.3. Subsequent Modification of final Fieldsfinal字段的后续修改
17.5.4. Write-Protected Fields写保护字段
17.6. Word Tearing单词撕裂
17.7. Non-Atomic Treatment of double and longdoublelong的非原子处理
18. Type Inference类型推断
18.1. Concepts and Notation概念和符号
18.1.1. Inference Variables推理变量
18.1.2. Constraint Formulas约束公式
18.1.3. Bounds界限
18.2. Reduction减少
18.2.1. Expression Compatibility Constraints表达式兼容性约束
18.2.2. Type Compatibility Constraints类型兼容性约束
18.2.3. Subtyping Constraints子类型约束
18.2.4. Type Equality Constraints类型相等约束
18.2.5. Checked Exception Constraints检查异常约束
18.3. Incorporation合并
18.3.1. Complementary Pairs of Bounds互补界对
18.3.2. Bounds Involving Capture Conversion涉及捕获转换的边界
18.4. Resolution解决
18.5. Uses of Inference推理的使用
18.5.1. Invocation Applicability Inference调用适用性推理
18.5.2. Invocation Type Inference调用类型推断
18.5.2.1. Poly Method Invocation Compatibility多方法调用兼容性
18.5.2.2. Additional Argument Constraints附加参数约束
18.5.3. Functional Interface Parameterization Inference函数接口参数化推理
18.5.4. More Specific Method Inference更具体的方法推理
19. Syntax语法
A. Limited License Grant有限许可证授予

List of Examples示例清单

3.10.5-1. String Literals字符串字面量
3.10.6-1. Text Blocks文本块
3.10.6-2. Escape sequences in text blocks文本块中的转义序列
3.10.6-3. Order of transformations on text block content文本块内容的转换顺序
3.10.6-4. Text blocks evaluate to String文本块计算为String
4.2.2-1. Integer Operations整数运算
4.2.4-1. Floating-point Operations浮点运算
4.3.1-1. Object Creation对象创建
4.3.1-2. Primitive and Reference Identity本原与参照恒等式
4.4-1. Members of a Type Variable类型变量的成员
4.5.1-1. Unbounded Wildcards无界通配符
4.5.1-2. Bounded Wildcards有界通配符
4.8-1. Raw Types原始类型
4.8-2. Raw Types and Inheritance原始类型和继承
4.11-1. Usage of a Type类型的用法
4.12.3-1. Different Kinds of Variables不同类型的变量
4.12.4-1. Final Variables最终变量
4.12.5-1. Initial Values of Variables变量的初始值
4.12.6-1. Type of a Variable versus Class of an Object变量的类型与对象的类
5.0-1. Conversions at Compile Time and Run Time编译时和运行时的转换
5.0-2. Conversions In Various Contexts不同语境下的转换
5.1.2-1. Widening Primitive Conversion扩大原语转换
5.1.3-1. Narrowing Primitive Conversion基本类型转换
5.1.3-2. Narrowing Primitive Conversions that lose information缩小丢失信息的原语转换范围
5.2-1. Assignment for Primitive Types基元类型的赋值
5.2-2. Assignment for Reference Types引用类型的赋值
5.2-3. Assignment for Array Types数组类型的赋值
5.5-1. Casting for Reference Types引用类型的转换
5.5-2. Casting for Array Types数组类型的强制转换
5.5-3. Casting Incompatible Types at Run Time在运行时强制转换不兼容的类型
5.6-1. Unary Numeric Promotion一元数字提升
5.6-2. Binary Numeric Promotion二进制数字升级
6.1-1. Unique Package Names唯一的包名称
6.1-2. Unique Module Names唯一模块名
6.1-3. Descriptive Class Names描述性类名
6.1-4. Conventional Type Variable Names常规类型变量名
6.3-1. Scope of Class Declarations类声明的范围
6.3-2. Scope of Local Variable Declarations局部变量声明的范围
6.4-1. Attempted Shadowing Of A Local Variable试图隐藏局部变量
6.4.1-1. Shadowing of a Field Declaration by a Local Variable Declaration局部变量声明对字段声明的隐藏
6.4.1-2. Shadowing of a Type Declaration by Another Type Declaration另一个类型声明对一个类型声明的隐藏
6.5.2-1. Reclassification of Contextually Ambiguous Names上下文歧义名称的重新分类
6.5.5.1-1. References to Type Parameters对类型参数的引用
6.5.5.2-1. Qualified Type Names限定类型名
6.5.6.1-1. Simple Expression Names简单表达式名称
6.5.6.1-2. References to Instance Variables对实例变量的引用
6.5.6.1-3. References to Local Variables and Formal Parameters对局部变量和形式参数的引用
6.5.6.2-1. Qualified Expression Names限定表达式名
6.5.6.2-2. Qualifying an Expression with a Type Name使用类型名称限定表达式
6.5.7.1-1. Simple Method Names简单方法名
6.6-1. Access Control访问控制
6.6-2. Access to public Fields, Methods, and Constructorspublic字段、方法和构造函数的访问
6.6-3. Access to public and Non-public Classes访问public和非public
6.6-4. Access to Package-Access Fields, Methods, and Constructors对包访问字段、方法和构造函数的访问
6.6-5. Access to private Fields, Methods, and Constructorsprivate字段、方法和构造函数的访问
6.6.2-1. Access to protected Fields, Methods, and Constructorsprotected字段、方法和构造函数的访问
6.7-1. Fully Qualified Names完全限定名
6.7-2. Fully Qualified Names v. Canonical Name完全限定名与典名的对比
7.4.2-1. Unnamed Package未命名包
7.5.1-1. Single-Type-Import单一类型导入
7.5.1-2. Duplicate Class Declarations重复的类声明
7.5.1-3. No Import of a Subpackage不导入子包
7.5.1-4. Importing a Type Name that is also a Package Name导入同时也是包名称的类型名称
7.5.2-1. Type-Import-on-Demand类型按需导入
7.6-1. Conflicting Top Level Class and Interface Declarations冲突的顶级类和接口声明
7.6-2. Scope of Top Level Classes and Interfaces顶级类和接口的范围
7.6-3. Fully Qualified Names完全限定名
7.1.1-1. Resolution of requires transitive directivesrequires transitive指令的解决
8.1.1.1-1. Abstract Class Declaration抽象类声明
8.1.1.1-2. Abstract Class Declaration that Prohibits Subclasses禁止子类的抽象类声明
8.1.2-1. Mutually Recursive Type Variable Bounds互递归型变量界
8.1.2-2. Nested Generic Classes嵌套泛型类
8.1.3-1. Inner Class Declarations and Static Members内部类声明和静态成员
8.1.3-2. Inner Class Declarations内部类声明
8.1.4-1. Direct Superclasses and Subclasses直接超类和子类
8.1.4-2. Superclasses and Subclasses超类和子类
8.1.4-3. Class Depends on Itself阶级自立
8.1.5-1. Illegal Superinterfaces非法超级接口
8.1.5-2. Superinterfaces超接口
8.1.5-3. Illegal Multiple Inheritance of an Interface接口的非法多重继承
8.1.5-4. Implementing Methods of a Superinterface超接口的实现方法
8.2-1. Use of Class Members使用类成员
8.2-2. Inheritance of Class Members with Package Access具有包访问权限的类成员的继承
8.2-3. Inheritance of public and protected Class Memberspublic类成员和protected类成员的继承
8.2-4. Inheritance of private Class Membersprivate类成员的继承
8.2-5. Accessing Members of Inaccessible Classes访问不可访问类的成员
8.3-1. Multiply Inherited Fields多重继承字段
8.3-2. Re-inheritance of Fields字段的重新继承
8.3.1.1-1. static Fields字段
8.3.1.1-2. Hiding of Class Variables类变量的隐藏
8.3.1.1-3. Hiding of Instance Variables实例变量的隐藏
8.3.1.3-1. Persistence of transient Fieldstransient字段的持续性
8.3.1.4-1. volatile Fields字段
8.3.2-1. Field Initialization字段初始化
8.3.2-2. Forward Reference to a Class Variable对类变量的正向引用
8.3.3-1. Restrictions on Field References对字段引用的限制
8.4.2-1. Override-Equivalent Signatures覆盖等效签名
8.4.3.1-1. Abstract/Abstract Method Overriding抽象/抽象方法重写
8.4.3.1-2. Abstract/Non-Abstract Overriding抽象/非抽象重写
8.4.3.6-1. synchronized Monitors监视器
8.4.3.6-2. synchronized Methods方法
8.4.6-1. Type Variables as Thrown Exception Types类型变量作为抛出的异常类型
8.4.8-1. Inheritance继承
8.4.8.1-1. Overriding重写
8.4.8.1-2. Overriding重写
8.4.8.2-1. Invocation of Hidden Class Methods调用隐藏类方法
8.4.8.3-1. Covariant Return Types协变返回类型
8.4.8.3-2. Unchecked Warning from Return Type来自返回类型的未选中警告
8.4.8.3-3. Incorrect Overriding because of throws由于Throw引发的错误重写
8.4.8.3-4. Erasure Affects Overriding擦除影响覆盖
8.4.9-1. Overloading重载
8.4.9-2. Overloading, Overriding, and Hiding重载、重写和隐藏
8.8-1. Constructor Declarations构造函数声明
8.8.7-1. Constructor Bodies构造体
8.8.7.1-1. Restrictions on Explicit Constructor Invocation Statements显式构造函数调用语句的限制
8.8.7.1-2. Qualified Superclass Constructor Invocation限定超类构造函数调用
8.8.9-1. Default Constructors默认构造函数
8.8.9-2. Accessibility of Constructors v. Classes构造函数和类的可访问性对比
8.8.10-1. Preventing Instantiation via Constructor Accessibility防止通过构造函数可访问性进行实例化
8.9.2-1. Enum Body Declarations枚举体声明
8.9.2-2. Restriction On Enum Constant Self-Reference枚举常量自引用的限制
8.9.3-1. Iterating Over Enum Constants With An Enhanced for Loop使用增强的for循环迭代枚举常量
8.9.3-2. Switching Over Enum Constants切换枚举常量
8.9.3-3. Enum Constants with Class Bodies带有类主体的枚举常量
8.9.3-4. Multiple Enum Classes多个枚举类
9.3-1. Ambiguous Inherited Fields不明确的继承字段
9.3-2. Multiply Inherited Fields多重继承字段
9.3.1-1. Forward Reference to a Field对字段的正向引用
9.4.2-1. Overloading an abstract Method Declarationabstract抽象方法声明
9.6.1-1. Annotation Interface Declaration注释接口声明
9.6.1-2. Marker Annotation Interface Declaration标记注释接口声明
9.6.1-3. Single-Element Annotation Interface Declarations单元素注释接口声明
9.6.2-1. Annotation Interface Declaration With Default Values带有默认值的注释接口声明
9.6.3-1. Ill-formed Containing Annotation Interface包含注释接口的格式错误
9.6.3-2. Restricting Where Annotations May Repeat限制注释可能重复的位置
9.6.3-3. A Repeatable Containing Annotation Interface可重复的包含注释的接口
9.7.1-1. Normal Annotations正常注释
9.7.2-1. Marker Annotations标记注释
9.7.3-1. Single-Element Annotations单元素注释
9.8-1. Functional Interfaces功能接口
9.8-2. Functional Interfaces and Erasure功能接口和擦除
9.8-3. Generic Functional Interfaces通用功能接口
9.9-1. Function Types函数类型
9.9-2. Generic Function Types泛型函数类型
10.2-1. Declarations of Array Variables数组变量的声明
10.2-2. Array Variables and Array Types数组变量和数组类型
10.4-1. Array Access阵列访问
10.5-1. ArrayStoreException
10.6-1. Array Initializers数组初始值设定项
10.7-1. Arrays Are Cloneable数组是可克隆的
10.7-2. Shared Subarrays After A Clone克隆后的共享子阵列
10.8-1. Class Object Of Array数组的Class对象
10.8-2. Array Class Objects Are Shared数组Class对象是共享的
11.2.3-1. Catching Checked Exceptions捕获已检查的异常
11.3-1. Throwing and Catching Exceptions抛出和捕获异常
12.4.1-1. Superclasses Are Initialized Before Subclasses超类在子类之前初始化
12.4.1-2. Only The Class That Declares static Field Is Initialized仅初始化声明static字段的类
12.4.1-3. Interface Initialization Does Not Initialize Superinterfaces接口初始化不初始化超级接口
12.5-1. Evaluation of Instance Creation实例创建的评估
12.5-2. Dynamic Dispatch During Instance Creation实例创建期间的动态调度
13.4.4-1. Changing A Superclass更改超类
13.4.4-2. Introducing a Superclass引入超类
13.4.6-1. Changing A Class Body更改类体
13.4.6-2. Changing A Superclass更改超类
13.4.7-1. Changing Accessibility更改可访问性
13.4.8-1. Adding A Field Declaration添加字段声明
13.4.9-1. Changing A Variable To Be final将变量更改为final变量
13.4.16-1. Changing A Method To Be abstract将方法更改为abstract方法
13.4.17-1. Changing A Method To Be final将方法更改为final方法
13.4.23-1. Adding An Overloaded Method添加重载方法
13.5.4-1. Deleting An Interface Member删除接口成员
13.5.7-1. Adding A Default Method添加默认方法
14.3-1. Local Class Declarations局部类声明
14.4-1. Local Variables Declared With varvar声明的局部变量
14.4.1-1. Type of Local Variables Declared With var使用var声明的局部变量的类型
14.7-1. Labels and Identifiers标签和标识符
14.11.3-1. Fall-Through in the switch Statementswitch语句中的Fall-Through
14.13-1. The do Statementdo语句
14.14-1. Enhanced for And Arrays增强的for和数组
14.14-2. Enhanced for And Unboxing Conversion增强的for和拆箱转换
14.15-1. The break Statementbreak语句
14.16-1. The continue Statementcontinue语句
14.19-1. The synchronized Statementsynchronized语句
14.20.1-1. Catching An Exception捕捉异常
14.20.2-1. Handling An Uncaught Exception With finally使用finally处理未捕获的异常
14.21-1. The yield Statementyield语句
14.22-1. Conditional Compilation条件编译
15.7.1-1. Left-Hand Operand Is Evaluated First首先计算左手操作数
15.7.1-2. Implicit Left-Hand Operand In Operator Of Compound Assigment复合赋值运算符中的隐式左手操作数
15.7.1-3. Abrupt Completion of Evaluation of the Left-Hand Operand左侧操作数求值的突然完成
15.7.2-1. Evaluation of Operands Before Operation运算前操作数的求值
15.7.4-1. Evaluation Order At Method Invocation方法调用时的求值顺序
15.7.4-2. Abrupt Completion of Argument Expression论元表达式的突然完成
15.8.3-1. The this Expressionthis表达式
15.9.4-1. Evaluation Order and Out-Of-Memory Detection评估顺序和内存不足检测
15.10.2-1. Array Creation Evaluation数组创建评估
15.10.2-2. Multi-Dimensional Array Creation多维数组创建
15.10.2-3. OutOfMemoryError and Dimension Expression Evaluation和维表达式求值
15.10.4-1. Array Reference Is Evaluated First首先计算数组引用
15.10.4-2. Abrupt Completion of Array Reference Evaluation阵列参考评估的突然完成
15.10.4-3. null Array Reference数组引用
15.11.1-1. Static Binding for Field Access用于字段访问的静态绑定
15.11.1-2. Receiver Variable Is Irrelevant For static Field Access接收器变量与static字段访问无关
15.11.2-1. The super Expressionsuper表达式
15.12.2-1. Method Applicability方法适用性
15.12.2-2. Return Type Not Considered During Method Selection方法选择期间未考虑返回类型
15.12.2-3. Choosing The Most Specific Method选择最具体的方法
15.12.4.1-1. Target References and static Methods目标引用和static方法
15.12.4.1-2. Evaluation Order During Method Invocation方法调用期间的求值顺序
15.12.4.4-1. Overriding and Method Invocation重写和方法调用
15.12.4.4-2. Method Invocation Using super使用super调用方法
15.12.4.5-1. Invoked Method Signature Has Different Erasure Than Compile-Time Method Signature调用的方法签名与编译时方法签名具有不同的擦除
15.17.3-1. Integer Remainder Operator整数余数运算符
15.17.3-2. Floating-Point Remainder Operator浮点余数运算符
15.18.1-1. String Concatenation字符串串联
15.18.1-2. String Concatenation and Conditionals字符串连接和条件
15.20.2-1. The Type Comparison Operator类型比较运算符
15.26.1-1. Simple Assignment To An Array Component数组组件的简单赋值
15.26.2-1. Compound Assignment To An Array Component对数组组件的复合赋值
15.26.2-2. Value Of Left-Hand Side Of Compound Assignment Is Saved Before Evaluation Of Right-Hand Side复合赋值的左侧值在右侧求值之前保存
15.29-1. Constant Expressions常量表达式
16-1. Definite Assignment Considers Structure of Statements and Expressions定赋值考虑语句和表达式的结构
16-2. Definite Assignment Does Not Consider Values of Expressions明确赋值不考虑表达式的值
16-3. Definite Unassignment确定取消分配
17.4-1. Incorrectly Synchronized Programs May Exhibit Surprising Behavior不正确同步的程序可能会表现出令人惊讶的行为
17.4.5-1. Happens-before Consistency发生在一致性之前
17.4.8-1. Happens-before Consistency Is Not Sufficient在一致性不足之前发生
17.5-1. final Fields In The Java Memory ModelJava内存模型中的final字段
17.5-2. final Fields For Security为了安全性的final字段
17.5.3-1. Aggressive Optimization of final Fieldsfinal字段的渐进优化
17.6-1. Detection of Word Tearing单词撕裂检测