、标签——直接编写 Markdown。' +- icon: 👁 + title: 编辑器中更美观 + desc: "Markdown 在现代 IDE 和文本编辑器中渲染效果极佳。" +support: + description: 自 JDK 23 起可用(2024 年 9 月) diff --git a/translations/content/zh-CN/language/module-import-declarations.yaml b/translations/content/zh-CN/language/module-import-declarations.yaml new file mode 100644 index 0000000..d885806 --- /dev/null +++ b/translations/content/zh-CN/language/module-import-declarations.yaml @@ -0,0 +1,18 @@ +--- +title: 模块导入声明 +oldApproach: 大量 import 语句 +modernApproach: import module +summary: "用单个声明导入模块导出的所有包。" +explanation: "模块导入声明让您用单个 import module 语句导入模块导出的所有内容,替代大量单独的包导入。" +whyModernWins: +- icon: 🧹 + title: 一行搞定 + desc: "用单个模块导入替代大量 import 语句。" +- icon: 📦 + title: 模块感知 + desc: "利用模块系统导入一致的包集合。" +- icon: 🚀 + title: 快速启动 + desc: "非常适合脚本和原型,无需繁琐的 import 列表。" +support: + description: 在 JDK 25 LTS 中正式发布(JEP 511,2025 年 9 月)。 diff --git a/translations/content/zh-CN/language/pattern-matching-instanceof.yaml b/translations/content/zh-CN/language/pattern-matching-instanceof.yaml new file mode 100644 index 0000000..0bfc6c6 --- /dev/null +++ b/translations/content/zh-CN/language/pattern-matching-instanceof.yaml @@ -0,0 +1,18 @@ +--- +title: instanceof 的模式匹配 +oldApproach: instanceof + 强制类型转换 +modernApproach: 模式变量 +summary: "通过模式匹配在一步中组合类型检查和转换。" +explanation: "instanceof 的模式匹配消除了 instanceof 检查后冗余的类型转换。绑定变量自动具有正确的类型和作用域。" +whyModernWins: +- icon: 🔄 + title: 无冗余转换 + desc: "类型检查和变量绑定在单个表达式中完成。" +- icon: 📏 + title: 更少代码行 + desc: "一行代替两行——转换行完全消失。" +- icon: 🛡️ + title: 作用域安全 + desc: "模式变量仅在保证类型正确的作用域内有效。" +support: + description: 自 JDK 16 起广泛可用(2021 年 3 月) diff --git a/translations/content/zh-CN/language/pattern-matching-switch.yaml b/translations/content/zh-CN/language/pattern-matching-switch.yaml new file mode 100644 index 0000000..2f1b869 --- /dev/null +++ b/translations/content/zh-CN/language/pattern-matching-switch.yaml @@ -0,0 +1,18 @@ +--- +title: switch 中的模式匹配 +oldApproach: if-else 链 +modernApproach: 类型模式 +summary: "用简洁的 switch 类型模式替代 if-else instanceof 链。" +explanation: "switch 中的模式匹配让您直接匹配类型,在单个 case 标签中组合类型检查、转换和绑定。" +whyModernWins: +- icon: 📐 + title: 结构化分派 + desc: "switch 使分支结构清晰可见且易于扫描。" +- icon: 🎯 + title: 表达式形式 + desc: "直接返回值——无需可变临时变量。" +- icon: ✅ + title: 穷举性 + desc: "编译器确保所有类型均已处理。" +support: + description: 自 JDK 21 LTS 起广泛可用(2023 年 9 月) diff --git a/translations/content/zh-CN/language/primitive-types-in-patterns.yaml b/translations/content/zh-CN/language/primitive-types-in-patterns.yaml new file mode 100644 index 0000000..6dddb82 --- /dev/null +++ b/translations/content/zh-CN/language/primitive-types-in-patterns.yaml @@ -0,0 +1,18 @@ +--- +title: 模式中的原始类型 +oldApproach: 手动范围检查 +modernApproach: 原始类型模式 +summary: "模式匹配现在适用于原始类型,不仅限于对象。" +explanation: "Java 25 将模式匹配扩展到原始类型。您可以在 instanceof 和 switch 中使用 int、long、double 等作为模式变量。" +whyModernWins: +- icon: 📦 + title: 无装箱 + desc: "直接匹配原始类型——无需 Integer 包装器。" +- icon: 🎯 + title: 模式一致性 + desc: "对象和原始类型使用相同的模式语法。" +- icon: ⚡ + title: 更好的性能 + desc: "避免模式匹配中的自动装箱开销。" +support: + description: JDK 25 预览版(第三次预览,JEP 507)。需要 --enable-preview。 diff --git a/translations/content/zh-CN/language/private-interface-methods.yaml b/translations/content/zh-CN/language/private-interface-methods.yaml new file mode 100644 index 0000000..0d48f8d --- /dev/null +++ b/translations/content/zh-CN/language/private-interface-methods.yaml @@ -0,0 +1,18 @@ +--- +title: 接口私有方法 +oldApproach: 重复逻辑 +modernApproach: 私有方法 +summary: "使用私有方法提取接口中的共享逻辑。" +explanation: "Java 9 允许在接口中使用私有方法,使您可以在默认方法之间共享代码,而不向实现类暴露实现细节。" +whyModernWins: +- icon: 🧩 + title: 代码复用 + desc: "在默认方法之间共享逻辑,避免重复。" +- icon: 🔐 + title: 封装 + desc: "实现细节对实现类保持隐藏。" +- icon: 🧹 + title: DRY 接口 + desc: "不再需要在默认方法之间复制粘贴。" +support: + description: 自 JDK 9 起广泛可用(2017 年 9 月) diff --git a/translations/content/zh-CN/language/record-patterns.yaml b/translations/content/zh-CN/language/record-patterns.yaml new file mode 100644 index 0000000..f5cd23c --- /dev/null +++ b/translations/content/zh-CN/language/record-patterns.yaml @@ -0,0 +1,18 @@ +--- +title: record 模式(解构) +oldApproach: 手动访问 +modernApproach: 解构 +summary: "直接在模式中解构 record——一步提取字段。" +explanation: "record 模式让您在 instanceof 和 switch 模式中直接分解 record 的组件。组件在单个表达式中绑定到变量。" +whyModernWins: +- icon: 🎯 + title: 直接提取 + desc: "无需手动调用访问器即可访问 record 组件。" +- icon: 🪆 + title: 可嵌套 + desc: "模式可以嵌套——在单个表达式中匹配内部 record。" +- icon: 📏 + title: 代码紧凑 + desc: "五行变两行——减少仪式感,保持清晰。" +support: + description: 自 JDK 21 LTS 起广泛可用(2023 年 9 月) diff --git a/translations/content/zh-CN/language/records-for-data-classes.yaml b/translations/content/zh-CN/language/records-for-data-classes.yaml new file mode 100644 index 0000000..05eac51 --- /dev/null +++ b/translations/content/zh-CN/language/records-for-data-classes.yaml @@ -0,0 +1,18 @@ +--- +title: 用 record 定义数据类 +oldApproach: 冗长的 POJO +modernApproach: record +summary: "一行代码替代不可变数据载体的 30 多行样板代码。" +explanation: "record 自动从组件列表生成构造函数、访问器(x()、y())、equals()、hashCode() 和 toString()。" +whyModernWins: +- icon: ⚡ + title: 一行定义 + desc: "单行代码替代构造函数、getter、equals、hashCode、toString。" +- icon: 🔒 + title: 默认不可变 + desc: "所有字段均为 final——没有 setter 的隐患。" +- icon: 🧩 + title: 模式友好 + desc: "record 可与 switch 和 instanceof 中的解构模式配合使用。" +support: + description: 自 JDK 16 起广泛可用(2021 年 3 月) diff --git a/translations/content/zh-CN/language/sealed-classes.yaml b/translations/content/zh-CN/language/sealed-classes.yaml new file mode 100644 index 0000000..439bbd1 --- /dev/null +++ b/translations/content/zh-CN/language/sealed-classes.yaml @@ -0,0 +1,18 @@ +--- +title: 用密封类定义类型层次 +oldApproach: 开放层次 +modernApproach: sealed permits +summary: "限制哪些类可以扩展某个类型——支持穷举 switch。" +explanation: "密封类定义了一组封闭的子类型。编译器在编译时知道所有可能的子类型,从而支持穷举 switch 表达式。" +whyModernWins: +- icon: 🔐 + title: 受控层次 + desc: "只有允许的子类型可以扩展——没有意外子类。" +- icon: ✅ + title: 穷举匹配 + desc: "编译器验证 switch 覆盖所有情况,无需 default。" +- icon: 📐 + title: 代数数据类型 + desc: "自然建模求和类型——密封类 + record = Java 中的 ADT。" +support: + description: 自 JDK 17 LTS 起广泛可用(2021 年 9 月) diff --git a/translations/content/zh-CN/language/static-members-in-inner-classes.yaml b/translations/content/zh-CN/language/static-members-in-inner-classes.yaml new file mode 100644 index 0000000..58ab9ee --- /dev/null +++ b/translations/content/zh-CN/language/static-members-in-inner-classes.yaml @@ -0,0 +1,18 @@ +--- +title: 内部类中的静态成员 +oldApproach: 必须使用静态嵌套类 +modernApproach: 内部类中的静态成员 +summary: "在内部类中定义静态成员,无需使用静态嵌套类。" +explanation: "Java 16 之前,只有静态嵌套类才能包含静态成员。Java 16 解除了这一限制,允许内部类声明静态字段和方法。" +whyModernWins: +- icon: 🔓 + title: 更大灵活性 + desc: "内部类现在可以在需要时拥有静态成员。" +- icon: 🧩 + title: 共享状态 + desc: "跨内部类实例追踪共享状态。" +- icon: 📐 + title: 设计自由 + desc: "无需仅为一个静态字段而将类提升为静态嵌套类。" +support: + description: 自 JDK 16 起广泛可用(2021 年 3 月) diff --git a/translations/content/zh-CN/language/static-methods-in-interfaces.yaml b/translations/content/zh-CN/language/static-methods-in-interfaces.yaml new file mode 100644 index 0000000..7c79de9 --- /dev/null +++ b/translations/content/zh-CN/language/static-methods-in-interfaces.yaml @@ -0,0 +1,18 @@ +--- +title: 接口中的静态方法 +oldApproach: 工具类 +modernApproach: 接口静态方法 +summary: "直接在接口中添加静态工具方法,而非单独的工具类。" +explanation: "Java 8 之前,与接口相关的工具方法必须放在配套的工具类中。接口上的静态方法将相关 API 聚合在一起。" +whyModernWins: +- icon: 📦 + title: 更好的组织 + desc: "将相关工具方法与接口放在一起,而非单独的类中。" +- icon: 🔍 + title: 可发现性 + desc: "工厂和辅助方法在您期望的地方找到。" +- icon: 🧩 + title: API 内聚性 + desc: "无需单独的 *Utils 或 *Helper 类。" +support: + description: 自 JDK 8 起可用(2014 年 3 月) diff --git a/translations/content/zh-CN/language/switch-expressions.yaml b/translations/content/zh-CN/language/switch-expressions.yaml new file mode 100644 index 0000000..81aba8b --- /dev/null +++ b/translations/content/zh-CN/language/switch-expressions.yaml @@ -0,0 +1,18 @@ +--- +title: switch 表达式 +oldApproach: switch 语句 +modernApproach: switch 表达式 +summary: "switch 作为返回值的表达式——无 break,无穿透。" +explanation: "switch 表达式直接返回值,使用箭头语法防止穿透,并要求穷举性。编译器检查所有情况是否已处理。" +whyModernWins: +- icon: 🎯 + title: 返回值 + desc: "直接赋值 switch 结果——无需临时变量。" +- icon: 🛡️ + title: 无穿透 + desc: "箭头语法消除因缺少 break 而导致的意外穿透 bug。" +- icon: ✅ + title: 穷举性检查 + desc: "编译器确保所有情况均已覆盖。" +support: + description: 自 JDK 14 起广泛可用(2020 年 3 月) diff --git a/translations/content/zh-CN/language/text-blocks-for-multiline-strings.yaml b/translations/content/zh-CN/language/text-blocks-for-multiline-strings.yaml new file mode 100644 index 0000000..e74985c --- /dev/null +++ b/translations/content/zh-CN/language/text-blocks-for-multiline-strings.yaml @@ -0,0 +1,18 @@ +--- +title: 多行字符串文本块 +oldApproach: 字符串拼接 +modernApproach: 文本块 +summary: "使用三引号文本块自然地编写多行字符串。" +explanation: "文本块让您以原始形式编写多行字符串。无需拼接,无需对嵌入引号进行转义,并自动去除缩进。" +whyModernWins: +- icon: 📖 + title: 所见即所得 + desc: "JSON、SQL 和 HTML 在源码中就像真正的 JSON、SQL 和 HTML。" +- icon: 🚫 + title: 无转义地狱 + desc: "嵌入的引号无需反斜杠转义。" +- icon: 📐 + title: 智能缩进 + desc: "根据结束分隔符的位置自动去除前导空白。" +support: + description: 自 JDK 15 起广泛可用(2020 年 9 月) diff --git a/translations/content/zh-CN/language/type-inference-with-var.yaml b/translations/content/zh-CN/language/type-inference-with-var.yaml new file mode 100644 index 0000000..f4a89c6 --- /dev/null +++ b/translations/content/zh-CN/language/type-inference-with-var.yaml @@ -0,0 +1,18 @@ +--- +title: 使用 var 进行类型推断 +oldApproach: 显式类型声明 +modernApproach: var 关键字 +summary: "使用 var 进行局部变量类型推断——减少噪音,同样安全。" +explanation: "自 Java 10 起,编译器从右侧表达式推断局部变量类型。这在不牺牲类型安全的情况下减少了视觉噪音。当类型从上下文中显而易见时,使用 var。" +whyModernWins: +- icon: ⚡ + title: 减少样板代码 + desc: "无需在赋值两侧重复复杂的泛型类型。" +- icon: 👁 + title: 提高可读性 + desc: "专注于变量名和值,而非类型声明。" +- icon: 🔒 + title: 仍然类型安全 + desc: 编译器在编译时推断并强制执行确切类型。 +support: + description: 自 JDK 10 起广泛可用(2018 年 3 月) diff --git a/translations/content/zh-CN/language/unnamed-variables.yaml b/translations/content/zh-CN/language/unnamed-variables.yaml new file mode 100644 index 0000000..097be37 --- /dev/null +++ b/translations/content/zh-CN/language/unnamed-variables.yaml @@ -0,0 +1,18 @@ +--- +title: 用 _ 表示未命名变量 +oldApproach: 未使用变量 +modernApproach: _ 占位符 +summary: "使用 _ 表示变量被有意忽略的意图。" +explanation: "未命名变量向读者和工具传达一个值被刻意忽略的信息。下划线在 Java 22+ 中是保留标识符。" +whyModernWins: +- icon: 📢 + title: 意图清晰 + desc: '_ 明确表示"此处不需要这个值"。' +- icon: 🔇 + title: 无警告 + desc: "IDE 和 linter 不会标记有意未使用的变量。" +- icon: 🧹 + title: 更简洁的 lambda + desc: "当只需要部分参数时,多参数 lambda 更简洁。" +support: + description: 在 JDK 22 中正式发布(JEP 456,2024 年 3 月)。 diff --git a/translations/content/zh-CN/security/key-derivation-functions.yaml b/translations/content/zh-CN/security/key-derivation-functions.yaml new file mode 100644 index 0000000..aa12a91 --- /dev/null +++ b/translations/content/zh-CN/security/key-derivation-functions.yaml @@ -0,0 +1,18 @@ +--- +title: 密钥派生函数 +oldApproach: 手动 PBKDF2 +modernApproach: KDF API +summary: "使用标准 KDF API 派生加密密钥。" +explanation: "KDF API 为密钥派生函数(如 HKDF 和 PBKDF2)提供标准接口。它使用构建器模式替代笨拙的 KeySpec 构造函数,使密钥派生更加清晰且不易出错。" +whyModernWins: +- icon: 📐 + title: 简洁的 API + desc: "构建器模式替代笨拙的 KeySpec 构造函数。" +- icon: 🔒 + title: 标准接口 + desc: "一致的 API 适用于不同的 KDF 算法。" +- icon: 🛡️ + title: 更少错误 + desc: "类型安全的构建器减少参数顺序错误的风险。" +support: + description: 在 JDK 25 LTS 中正式发布(JEP 510,2025 年 9 月)。 diff --git a/translations/content/zh-CN/security/pem-encoding.yaml b/translations/content/zh-CN/security/pem-encoding.yaml new file mode 100644 index 0000000..f31a26d --- /dev/null +++ b/translations/content/zh-CN/security/pem-encoding.yaml @@ -0,0 +1,18 @@ +--- +title: PEM 编码/解码 +oldApproach: 手动 Base64 + 标头 +modernApproach: PEM API +summary: "原生编码和解码 PEM 格式的加密对象。" +explanation: "PEM API 为证书、密钥、CSR 等提供标准编码/解码。不再需要手动处理 Base64 编码、PEM 标头和行换行。" +whyModernWins: +- icon: 🧹 + title: 无手动 Base64 + desc: "PEM 标头、行换行和 Base64 自动处理。" +- icon: 📐 + title: 标准格式 + desc: "符合 RFC 7468 的 PEM 编码。" +- icon: 🔒 + title: 类型安全 + desc: "按类型解码——证书、私钥、公钥等。" +support: + description: JDK 25 预览版(JEP 470)。需要 --enable-preview。 diff --git a/translations/content/zh-CN/security/random-generator.yaml b/translations/content/zh-CN/security/random-generator.yaml new file mode 100644 index 0000000..4cefaa9 --- /dev/null +++ b/translations/content/zh-CN/security/random-generator.yaml @@ -0,0 +1,18 @@ +--- +title: RandomGenerator 接口 +oldApproach: new Random() / ThreadLocalRandom +modernApproach: RandomGenerator 工厂 +summary: "使用 RandomGenerator 接口按名称选择随机数算法。" +explanation: "JDK 17 引入 RandomGenerator 作为所有 RNG 实现的通用接口。通过名称选择算法,可以轻松切换实现而无需更改代码结构。" +whyModernWins: +- icon: 🔧 + title: 算法无关 + desc: "按名称选择最佳 RNG 算法,无需更改代码结构。" +- icon: 📐 + title: 统一接口 + desc: "所有随机数生成器共享相同的接口。" +- icon: ⚡ + title: 更好的算法 + desc: "访问 L64X128MixRandom 等现代高质量 PRNG。" +support: + description: 自 JDK 17 起可用(2021 年 9 月,JEP 356)。 diff --git a/translations/content/zh-CN/security/strong-random.yaml b/translations/content/zh-CN/security/strong-random.yaml new file mode 100644 index 0000000..2b87828 --- /dev/null +++ b/translations/content/zh-CN/security/strong-random.yaml @@ -0,0 +1,18 @@ +--- +title: 强随机数生成 +oldApproach: new SecureRandom() +modernApproach: getInstanceStrong() +summary: "获取平台最强的 SecureRandom 实现。" +explanation: "getInstanceStrong() 返回由 securerandom.strongAlgorithms 安全属性配置的最强 SecureRandom 实现。它自动选择平台的最佳安全算法。" +whyModernWins: +- icon: 🛡️ + title: 最强可用 + desc: "自动为平台选择最佳算法。" +- icon: 🔧 + title: 可配置 + desc: "通过安全属性在不同环境中自定义算法。" +- icon: 📖 + title: 意图清晰 + desc: "getInstanceStrong() 明确表明您需要最强的实现。" +support: + description: 自 JDK 9 起广泛可用(2017 年 9 月) diff --git a/translations/content/zh-CN/security/tls-default.yaml b/translations/content/zh-CN/security/tls-default.yaml new file mode 100644 index 0000000..9eaccb2 --- /dev/null +++ b/translations/content/zh-CN/security/tls-default.yaml @@ -0,0 +1,18 @@ +--- +title: 默认 TLS 1.3 +oldApproach: 手动 TLS 配置 +modernApproach: TLS 1.3 默认 +summary: "TLS 1.3 默认启用——无需显式协议配置。" +explanation: "Java 11 添加了 TLS 1.3 支持并将其设为首选协议。SSLContext 自动协商 TLS 1.3(如果双方都支持),使现有代码更加安全,无需更改。" +whyModernWins: +- icon: 🛡️ + title: 更安全 + desc: "TLS 1.3 删除了过时的密码套件和握手模式。" +- icon: ⚡ + title: 更快握手 + desc: "TLS 1.3 将往返次数从 2 减少到 1。" +- icon: 🆓 + title: 无配置 + desc: "现有 HTTPS 代码自动受益。" +support: + description: 自 JDK 11 起广泛可用(2018 年 9 月) diff --git a/translations/content/zh-CN/streams/collectors-flatmapping.yaml b/translations/content/zh-CN/streams/collectors-flatmapping.yaml new file mode 100644 index 0000000..61fd115 --- /dev/null +++ b/translations/content/zh-CN/streams/collectors-flatmapping.yaml @@ -0,0 +1,18 @@ +--- +title: Collectors.flatMapping() +oldApproach: 嵌套 flatMap +modernApproach: flatMapping() +summary: "使用 flatMapping() 在分组收集器内部进行扁平化。" +explanation: "Collectors.flatMapping() 在 groupingBy 等收集器内部将一对多映射作为下游收集器应用。这避免了 groupingBy 和 flatMap 的笨拙嵌套。" +whyModernWins: +- icon: 🧩 + title: 可组合 + desc: "作为 groupingBy 内的下游收集器使用。" +- icon: 📏 + title: 更扁平 + desc: "避免嵌套的 stream-inside-collector 模式。" +- icon: 📖 + title: 表达性强 + desc: "flatMapping 的意图一目了然。" +support: + description: 自 JDK 9 起广泛可用(2017 年 9 月) diff --git a/translations/content/zh-CN/streams/optional-ifpresentorelse.yaml b/translations/content/zh-CN/streams/optional-ifpresentorelse.yaml new file mode 100644 index 0000000..5578072 --- /dev/null +++ b/translations/content/zh-CN/streams/optional-ifpresentorelse.yaml @@ -0,0 +1,18 @@ +--- +title: Optional.ifPresentOrElse() +oldApproach: Optional 上的 if/else +modernApproach: ifPresentOrElse() +summary: "在一次调用中处理 Optional 的存在和缺失两种情况。" +explanation: "ifPresentOrElse() 接受一个用于存在情况的 Consumer 和一个用于缺失情况的 Runnable。这消除了对 Optional 进行 if/else 的需要。" +whyModernWins: +- icon: 📏 + title: 单个表达式 + desc: "两种情况在一次方法调用中处理。" +- icon: 📖 + title: 声明式 + desc: "直接表达存在和缺失两种处理路径。" +- icon: 🚫 + title: 无 isPresent() 检查 + desc: "避免手动 isPresent() + get() 模式。" +support: + description: 自 JDK 9 起广泛可用(2017 年 9 月) diff --git a/translations/content/zh-CN/streams/optional-or.yaml b/translations/content/zh-CN/streams/optional-or.yaml new file mode 100644 index 0000000..d46d3a6 --- /dev/null +++ b/translations/content/zh-CN/streams/optional-or.yaml @@ -0,0 +1,18 @@ +--- +title: Optional.or() 回退 +oldApproach: 嵌套回退 +modernApproach: .or() 链 +summary: "无需嵌套检查即可链式调用 Optional 回退。" +explanation: "Optional.or() 在有值时返回原始 Optional,否则返回由提供的 Supplier 生成的另一个 Optional。与 orElse() 不同,它保持 Optional 类型。" +whyModernWins: +- icon: 🔗 + title: 可链式调用 + desc: "在可读的管道中堆叠回退。" +- icon: 🎯 + title: 保持 Optional + desc: "返回 Optional
而非 T,因此可以继续链式调用。" +- icon: 📏 + title: 扁平 + desc: "无嵌套的 isPresent() 检查。" +support: + description: 自 JDK 9 起广泛可用(2017 年 9 月) diff --git a/translations/content/zh-CN/streams/predicate-not.yaml b/translations/content/zh-CN/streams/predicate-not.yaml new file mode 100644 index 0000000..e7ca159 --- /dev/null +++ b/translations/content/zh-CN/streams/predicate-not.yaml @@ -0,0 +1,18 @@ +--- +title: 用 Predicate.not() 进行否定 +oldApproach: Lambda 否定 +modernApproach: Predicate.not() +summary: "使用 Predicate.not() 简洁地否定方法引用,而非编写 lambda 包装器。" +explanation: "Java 11 之前,否定方法引用需要将其包装在 lambda 中。Predicate.not() 允许直接否定方法引用,保持代码简洁。" +whyModernWins: +- icon: 👁 + title: 更简洁的否定 + desc: "无需仅为否定而将方法引用包装在 lambda 中。" +- icon: 📖 + title: 可读性强 + desc: "Predicate.not(String::isBlank) 清晰地表达意图。" +- icon: 🔗 + title: 可组合 + desc: "与其他 Predicate 方法如 and()、or() 配合使用。" +support: + description: 自 JDK 11 起可用(2018 年 9 月)。 diff --git a/translations/content/zh-CN/streams/stream-gatherers.yaml b/translations/content/zh-CN/streams/stream-gatherers.yaml new file mode 100644 index 0000000..0a20230 --- /dev/null +++ b/translations/content/zh-CN/streams/stream-gatherers.yaml @@ -0,0 +1,18 @@ +--- +title: 流 Gatherer +oldApproach: 自定义 Collector +modernApproach: gather() +summary: "使用 Gatherer 实现自定义中间流操作。" +explanation: "Gatherer 是一种新的中间流操作,可以表达内置操作(如 map 和 filter)无法表达的复杂转换。它们支持有状态处理和提前终止。" +whyModernWins: +- icon: 🧩 + title: 可组合 + desc: "Gatherer 与其他流操作组合使用。" +- icon: 🎯 + title: 有状态 + desc: "与 map/filter 不同,Gatherer 可以在元素之间维护状态。" +- icon: 🔀 + title: 灵活 + desc: "可以扩展、收缩或转换流,不受内置操作限制。" +support: + description: 在 JDK 24 中正式发布(JEP 485,2025 年 3 月)。 diff --git a/translations/content/zh-CN/streams/stream-iterate-predicate.yaml b/translations/content/zh-CN/streams/stream-iterate-predicate.yaml new file mode 100644 index 0000000..4f3e6b6 --- /dev/null +++ b/translations/content/zh-CN/streams/stream-iterate-predicate.yaml @@ -0,0 +1,18 @@ +--- +title: 带谓词的 Stream.iterate() +oldApproach: iterate + limit +modernApproach: iterate(seed, pred, op) +summary: "使用谓词停止迭代——流形式的 for 循环。" +explanation: "三参数 Stream.iterate(seed, hasNext, next) 像 for 循环一样工作:从种子值开始,在谓词成立时继续,并按步骤函数递进。" +whyModernWins: +- icon: 🎯 + title: 自然终止 + desc: "根据条件停止,而非任意 limit。" +- icon: 📖 + title: for 循环的流形式 + desc: "for(int i=0; i<10; i++) 对应的流形式。" +- icon: 🔗 + title: 可链式调用 + desc: "与 map、filter 等其他流操作链式调用。" +support: + description: 自 JDK 9 起广泛可用(2017 年 9 月) diff --git a/translations/content/zh-CN/streams/stream-mapmulti.yaml b/translations/content/zh-CN/streams/stream-mapmulti.yaml new file mode 100644 index 0000000..494e67a --- /dev/null +++ b/translations/content/zh-CN/streams/stream-mapmulti.yaml @@ -0,0 +1,18 @@ +--- +title: Stream.mapMulti() +oldApproach: flatMap + List +modernApproach: mapMulti() +summary: "每个输入元素发出零个或多个元素,无需创建中间流。" +explanation: "mapMulti() 是 flatMap 的命令式替代方案,避免了为每个元素创建中间 Stream 或集合。使用 Consumer 按需发出元素。" +whyModernWins: +- icon: ⚡ + title: 更少分配 + desc: "每个元素不创建中间 Stream。" +- icon: 🎯 + title: 零或多个输出 + desc: "每个输入可以映射到任意数量的输出,包括零。" +- icon: 🔧 + title: 命令式控制 + desc: "比 flatMap 更精细地控制元素发出。" +support: + description: 自 JDK 16 起广泛可用(2021 年 3 月) diff --git a/translations/content/zh-CN/streams/stream-of-nullable.yaml b/translations/content/zh-CN/streams/stream-of-nullable.yaml new file mode 100644 index 0000000..d7d6921 --- /dev/null +++ b/translations/content/zh-CN/streams/stream-of-nullable.yaml @@ -0,0 +1,18 @@ +--- +title: Stream.ofNullable() +oldApproach: Null 检查 +modernApproach: ofNullable() +summary: "从可空值创建零或一个元素的流。" +explanation: "Stream.ofNullable() 在值非 null 时返回单元素流,在 null 时返回空流。这是 flatMap 中处理可空映射的理想选择。" +whyModernWins: +- icon: 📏 + title: 简洁 + desc: "一次调用替代三元条件表达式。" +- icon: 🔗 + title: 可链式调用 + desc: "在 flatMap 中完美配合可空映射使用。" +- icon: 🚫 + title: 无 null 检查 + desc: "不需要显式 null 守卫。" +support: + description: 自 JDK 9 起广泛可用(2017 年 9 月) diff --git a/translations/content/zh-CN/streams/stream-takewhile-dropwhile.yaml b/translations/content/zh-CN/streams/stream-takewhile-dropwhile.yaml new file mode 100644 index 0000000..bb807d8 --- /dev/null +++ b/translations/content/zh-CN/streams/stream-takewhile-dropwhile.yaml @@ -0,0 +1,18 @@ +--- +title: 流的 takeWhile / dropWhile +oldApproach: 手动循环 +modernApproach: takeWhile/dropWhile +summary: "根据谓词获取或丢弃流中的元素。" +explanation: "takeWhile() 在谓词为 true 时返回元素,在第一次失败时停止。dropWhile() 在谓词为 true 时跳过元素,然后返回其余所有元素。" +whyModernWins: +- icon: 🎯 + title: 短路 + desc: "一旦谓词失败立即停止处理。" +- icon: 📖 + title: 声明式 + desc: "清晰地表达获取/丢弃语义。" +- icon: 🔗 + title: 可链式调用 + desc: "与其他流操作无缝组合。" +support: + description: 自 JDK 9 起广泛可用(2017 年 9 月) diff --git a/translations/content/zh-CN/streams/stream-tolist.yaml b/translations/content/zh-CN/streams/stream-tolist.yaml new file mode 100644 index 0000000..b2e5751 --- /dev/null +++ b/translations/content/zh-CN/streams/stream-tolist.yaml @@ -0,0 +1,18 @@ +--- +title: Stream.toList() +oldApproach: Collectors.toList() +modernApproach: .toList() +summary: "终端操作 toList() 替代冗长的 collect(Collectors.toList())。" +explanation: "Stream.toList() 返回不可修改的列表。它等效于 .collect(Collectors.toUnmodifiableList()) 但更简短。注意:结果是不可变的,与 Collectors.toList() 不同。" +whyModernWins: +- icon: 📏 + title: 7 个字符 vs 24 个 + desc: ".toList() 替代 .collect(Collectors.toList())。" +- icon: 🔒 + title: 不可变 + desc: "结果列表不可修改。" +- icon: 📖 + title: 流畅 + desc: "在管道末尾读起来自然。" +support: + description: 自 JDK 16 起广泛可用(2021 年 3 月) diff --git a/translations/content/zh-CN/streams/virtual-thread-executor.yaml b/translations/content/zh-CN/streams/virtual-thread-executor.yaml new file mode 100644 index 0000000..3e1eb32 --- /dev/null +++ b/translations/content/zh-CN/streams/virtual-thread-executor.yaml @@ -0,0 +1,18 @@ +--- +title: 虚拟线程执行器 +oldApproach: 固定线程池 +modernApproach: 虚拟线程执行器 +summary: "使用虚拟线程执行器实现无限轻量并发。" +explanation: "虚拟线程执行器为每个任务创建新的虚拟线程。无需调整池大小——JVM 根据需要管理虚拟线程,开销极低。" +whyModernWins: +- icon: ♾️ + title: 无需调整大小 + desc: "无需调整池大小——按需创建任意数量的线程。" +- icon: ⚡ + title: 轻量级 + desc: "每个虚拟线程的内存占用仅为千字节。" +- icon: 🔧 + title: 熟悉的 API + desc: "与现有 ExecutorService 代码无缝配合。" +support: + description: 自 JDK 21 LTS 起广泛可用(2023 年 9 月) diff --git a/translations/content/zh-CN/strings/string-chars-stream.yaml b/translations/content/zh-CN/strings/string-chars-stream.yaml new file mode 100644 index 0000000..43ffb1a --- /dev/null +++ b/translations/content/zh-CN/strings/string-chars-stream.yaml @@ -0,0 +1,18 @@ +--- +title: 字符串字符流 +oldApproach: 手动循环 +modernApproach: chars() 流 +summary: "将字符串字符作为流管道处理。" +explanation: "String.chars() 返回字符值的 IntStream,支持函数式字符处理。使用 (char) 转换或 Character 方法处理各个字符。" +whyModernWins: +- icon: 🔗 + title: 可链式调用 + desc: "对字符流使用 filter、map、collect。" +- icon: 📖 + title: 函数式风格 + desc: "声明式字符处理,无命令式循环。" +- icon: 🧩 + title: 可组合 + desc: "与其他流操作无缝组合。" +support: + description: 自 JDK 8+ 起可用(JDK 9+ 中有所改进) diff --git a/translations/content/zh-CN/strings/string-formatted.yaml b/translations/content/zh-CN/strings/string-formatted.yaml new file mode 100644 index 0000000..cd7921d --- /dev/null +++ b/translations/content/zh-CN/strings/string-formatted.yaml @@ -0,0 +1,18 @@ +--- +title: String.formatted() +oldApproach: String.format() +modernApproach: formatted() +summary: "直接在模板字符串上调用 formatted()。" +explanation: "String.formatted() 是等效于 String.format() 的实例方法,但在模板字符串上调用。这消除了将同一字符串传递两次的需要。" +whyModernWins: +- icon: 📖 + title: 读起来自然 + desc: "template.formatted(args) 比 String.format(template, args) 更流畅。" +- icon: 📏 + title: 更短 + desc: "无需重复字符串变量名。" +- icon: 🔗 + title: 可链式调用 + desc: "可与其他字符串方法链式调用。" +support: + description: 自 JDK 15 起广泛可用(2020 年 9 月) diff --git a/translations/content/zh-CN/strings/string-indent-transform.yaml b/translations/content/zh-CN/strings/string-indent-transform.yaml new file mode 100644 index 0000000..4f71739 --- /dev/null +++ b/translations/content/zh-CN/strings/string-indent-transform.yaml @@ -0,0 +1,18 @@ +--- +title: String.indent() 和 transform() +oldApproach: 手动缩进 +modernApproach: indent() / transform() +summary: "流畅地缩进文本并链式进行字符串转换。" +explanation: "indent(n) 为每行添加 n 个空格。transform(fn) 将任意函数应用于字符串,支持在字符串操作管道中链式调用任何转换。" +whyModernWins: +- icon: 📏 + title: 内置方法 + desc: "缩进是常见操作——现在只需一次调用。" +- icon: 🔗 + title: 可链式调用 + desc: "transform() 允许将自定义函数插入字符串管道。" +- icon: 🧹 + title: 更简洁 + desc: "无需 StringBuilder 循环进行缩进。" +support: + description: 自 JDK 12 起广泛可用(2019 年 3 月) diff --git a/translations/content/zh-CN/strings/string-isblank.yaml b/translations/content/zh-CN/strings/string-isblank.yaml new file mode 100644 index 0000000..a100a57 --- /dev/null +++ b/translations/content/zh-CN/strings/string-isblank.yaml @@ -0,0 +1,18 @@ +--- +title: String.isBlank() +oldApproach: trim().isEmpty() +modernApproach: isBlank() +summary: "用单个方法调用检查空白字符串。" +explanation: "isBlank() 在字符串为空或只包含空白字符时返回 true,使用与 strip() 相同的 Unicode 感知规则——而不像 trim() 那样仅限于 ASCII 空白。" +whyModernWins: +- icon: 📖 + title: 自我描述 + desc: "isBlank() 准确说明它检查的内容。" +- icon: 🌐 + title: Unicode 正确 + desc: "使用与 strip() 相同的 Unicode 空白定义。" +- icon: 📏 + title: 更少链式调用 + desc: "一个方法替代两个链式调用。" +support: + description: 自 JDK 11 起广泛可用(2018 年 9 月) diff --git a/translations/content/zh-CN/strings/string-lines.yaml b/translations/content/zh-CN/strings/string-lines.yaml new file mode 100644 index 0000000..c9eb247 --- /dev/null +++ b/translations/content/zh-CN/strings/string-lines.yaml @@ -0,0 +1,18 @@ +--- +title: 用 String.lines() 分割行 +oldApproach: split("\\n") +modernApproach: lines() +summary: "使用 String.lines() 将文本分割为行流,无正则表达式开销。" +explanation: "String.lines() 返回按 \\n、\\r 或 \\r\\n 分割的行的 Stream 。它是懒加载的,并正确处理所有行分隔符,无需正则表达式。" +whyModernWins: +- icon: ⚡ + title: 懒加载流 + desc: "行按需生成,不像 split() 那样一次全部生成。" +- icon: 🌐 + title: 正确的行分隔符 + desc: "处理 \\n、\\r\\n 和 \\r,无需正则表达式。" +- icon: 🔗 + title: 可链式调用 + desc: "直接链式调用 filter、map 和其他流操作。" +support: + description: 自 JDK 11 起可用(2018 年 9 月)。 diff --git a/translations/content/zh-CN/strings/string-repeat.yaml b/translations/content/zh-CN/strings/string-repeat.yaml new file mode 100644 index 0000000..760b8f5 --- /dev/null +++ b/translations/content/zh-CN/strings/string-repeat.yaml @@ -0,0 +1,18 @@ +--- +title: String.repeat() +oldApproach: StringBuilder 循环 +modernApproach: repeat() +summary: "无需循环即可重复字符串 n 次。" +explanation: "String.repeat(int) 返回字符串与自身拼接 n 次的结果。对于 0 返回空字符串,对于负数抛出 IllegalArgumentException。" +whyModernWins: +- icon: 📏 + title: 一行代码 + desc: "用一次调用替代 5 行 StringBuilder 代码。" +- icon: 📖 + title: 意图清晰 + desc: "\"=-\".repeat(20) 明确表达意图。" +- icon: 🚫 + title: 无循环 + desc: "无需手动维护计数器和 StringBuilder。" +support: + description: 自 JDK 11 起广泛可用(2018 年 9 月) diff --git a/translations/content/zh-CN/strings/string-strip.yaml b/translations/content/zh-CN/strings/string-strip.yaml new file mode 100644 index 0000000..5871c9c --- /dev/null +++ b/translations/content/zh-CN/strings/string-strip.yaml @@ -0,0 +1,18 @@ +--- +title: String.strip() 与 trim() +oldApproach: trim() +modernApproach: strip() +summary: "使用 strip()、stripLeading()、stripTrailing() 进行 Unicode 感知的去空白处理。" +explanation: "trim() 只删除 ≤ U+0020 的字符(ASCII 控制字符和空格)。strip() 使用 Character.isWhitespace() 删除所有 Unicode 空白字符,包括不间断空格等。" +whyModernWins: +- icon: 🌐 + title: Unicode 正确 + desc: "处理来自每种文字的所有空白字符。" +- icon: 🎯 + title: 精确控制 + desc: "stripLeading() 和 stripTrailing() 提供单侧去除。" +- icon: 📖 + title: 语义更清晰 + desc: "strip() 的名称更准确地描述了现代空白处理。" +support: + description: 自 JDK 11 起广泛可用(2018 年 9 月) diff --git a/translations/content/zh-CN/tooling/aot-class-preloading.yaml b/translations/content/zh-CN/tooling/aot-class-preloading.yaml new file mode 100644 index 0000000..22d5408 --- /dev/null +++ b/translations/content/zh-CN/tooling/aot-class-preloading.yaml @@ -0,0 +1,18 @@ +--- +title: AOT 类预加载 +oldApproach: 每次冷启动 +modernApproach: AOT 缓存 +summary: "缓存类加载和编译,实现即时启动。" +explanation: "AOT 类预加载从训练运行中缓存已加载和链接的类。后续运行直接从缓存加载,跳过类加载、验证和链接。" +whyModernWins: +- icon: ⚡ + title: 更快启动 + desc: "跳过类加载、验证和链接。" +- icon: 🔧 + title: 零代码更改 + desc: "无需修改应用程序代码。" +- icon: 📦 + title: 容器友好 + desc: "显著改善容器化 Java 应用的启动时间。" +support: + description: 在 JDK 25 LTS 中作为标准特性可用(JEP 514/515,2025 年 9 月) diff --git a/translations/content/zh-CN/tooling/built-in-http-server.yaml b/translations/content/zh-CN/tooling/built-in-http-server.yaml new file mode 100644 index 0000000..85ad6ff --- /dev/null +++ b/translations/content/zh-CN/tooling/built-in-http-server.yaml @@ -0,0 +1,18 @@ +--- +title: 内置 HTTP 服务器 +oldApproach: 外部服务器/框架 +modernApproach: jwebserver CLI +summary: "Java 18 内置了一个最小化 HTTP 服务器,用于原型开发和文件服务。" +explanation: "JDK 18 通过 jwebserver CLI 工具和 com.sun.net.httpserver 包添加了一个简单的、零依赖的 HTTP 文件服务器。" +whyModernWins: +- icon: 🚀 + title: 零设置 + desc: "在任意目录运行 jwebserver——无需安装、配置或依赖。" +- icon: 🎓 + title: 适合演示 + desc: "无需框架即可提供静态文件和演示原型。" +- icon: 🔧 + title: 可编程 + desc: "通过 Java API 可编程地嵌入最小化 HTTP 服务器。" +support: + description: 自 JDK 18 起可用(2022 年 3 月) diff --git a/translations/content/zh-CN/tooling/compact-object-headers.yaml b/translations/content/zh-CN/tooling/compact-object-headers.yaml new file mode 100644 index 0000000..b47841e --- /dev/null +++ b/translations/content/zh-CN/tooling/compact-object-headers.yaml @@ -0,0 +1,18 @@ +--- +title: 紧凑对象头 +oldApproach: 128 位头 +modernApproach: 64 位头 +summary: "将对象头大小减半,提高内存密度和缓存利用率。" +explanation: "紧凑对象头将每个对象的开销从 128 位(16 字节)减少到 64 位(8 字节)。这提高了内存密度,减少了 GC 压力,并提高了缓存局部性。" +whyModernWins: +- icon: 📦 + title: 头部缩小 50% + desc: "每个对象 8 字节而非 16 字节。" +- icon: ⚡ + title: 更好的缓存 + desc: "更小的对象意味着每个缓存行容纳更多对象。" +- icon: 🔧 + title: 零代码更改 + desc: "无需修改应用程序代码。" +support: + description: 在 JDK 25 LTS 中正式发布(JEP 519,2025 年 9 月)。 diff --git a/translations/content/zh-CN/tooling/jfr-profiling.yaml b/translations/content/zh-CN/tooling/jfr-profiling.yaml new file mode 100644 index 0000000..490e0fd --- /dev/null +++ b/translations/content/zh-CN/tooling/jfr-profiling.yaml @@ -0,0 +1,18 @@ +--- +title: 用 JFR 进行性能分析 +oldApproach: 外部分析器 +modernApproach: Java Flight Recorder +summary: "使用内置的 Flight Recorder 分析任何 Java 应用——无需外部工具。" +explanation: "Java Flight Recorder(JFR)是 JVM 内置的低开销分析工具。它记录 JVM、OS 和应用程序事件,可用于性能分析、诊断和监控。" +whyModernWins: +- icon: 🆓 + title: 内置 + desc: "无需安装或许可外部分析器。" +- icon: ⚡ + title: 低开销 + desc: "生产级分析,开销 < 1%。" +- icon: 📊 + title: 丰富数据 + desc: "CPU、内存、GC、线程、I/O 和自定义事件。" +support: + description: 自 JDK 9/11 起广泛可用(在 11 中开源) diff --git a/translations/content/zh-CN/tooling/jshell-prototyping.yaml b/translations/content/zh-CN/tooling/jshell-prototyping.yaml new file mode 100644 index 0000000..a4114f6 --- /dev/null +++ b/translations/content/zh-CN/tooling/jshell-prototyping.yaml @@ -0,0 +1,18 @@ +--- +title: 用 JShell 进行原型开发 +oldApproach: 创建文件 + 编译 + 运行 +modernApproach: jshell REPL +summary: "无需创建文件即可交互式尝试 Java 表达式。" +explanation: "JShell 是 Java 的读取-求值-打印循环(REPL)。无需完整的类定义即可测试表达式、实验 API 并探索库。" +whyModernWins: +- icon: ⚡ + title: 即时反馈 + desc: "输入表达式,立即看到结果。" +- icon: 🎓 + title: 适合学习 + desc: "非常适合探索 API 和学习 Java 特性。" +- icon: 🔧 + title: 无文件 + desc: "无需创建类或文件即可测试代码片段。" +support: + description: 自 JDK 9 起广泛可用(2017 年 9 月) diff --git a/translations/content/zh-CN/tooling/junit6-with-jspecify.yaml b/translations/content/zh-CN/tooling/junit6-with-jspecify.yaml new file mode 100644 index 0000000..20192b5 --- /dev/null +++ b/translations/content/zh-CN/tooling/junit6-with-jspecify.yaml @@ -0,0 +1,18 @@ +--- +title: 使用 JSpecify null 安全的 JUnit 6 +oldApproach: 未注解的 API +modernApproach: '@NullMarked API' +summary: "JUnit 6 采用 JSpecify @NullMarked,使 null 契约在整个测试 API 中显式化。" +explanation: "JUnit 5 发布时没有标准化的可空性注解,让工具和开发者不得不猜测 null 行为。JUnit 6 使用 JSpecify 的 @NullMarked 将非 null 作为默认值。" +whyModernWins: +- icon: 📜 + title: 显式契约 + desc: "@NullMarked 在 JUnit 6 模块上直接记录 null 语义。" +- icon: 🔒 + title: 工具支持 + desc: "IDE 和分析器可以在测试代码中标记 null 违规。" +- icon: 🧹 + title: 更少 @Nullable + desc: "非 null 是默认值——只有异常需要注解。" +support: + description: 自 JUnit 6.0 起可用(2025 年 10 月,需要 Java 17+) diff --git a/translations/content/zh-CN/tooling/multi-file-source.yaml b/translations/content/zh-CN/tooling/multi-file-source.yaml new file mode 100644 index 0000000..db4a989 --- /dev/null +++ b/translations/content/zh-CN/tooling/multi-file-source.yaml @@ -0,0 +1,18 @@ +--- +title: 多文件源代码启动器 +oldApproach: 先编译所有文件 +modernApproach: 源代码启动器 +summary: "无需显式编译步骤即可启动多文件程序。" +explanation: "Java 22+ 在启动入口文件时可以自动编译引用的源文件。这对小型多文件程序消除了显式的 javac 步骤。" +whyModernWins: +- icon: 🚀 + title: 零设置 + desc: "小型多文件程序无需构建工具。" +- icon: ⚡ + title: 一个命令 + desc: "java Main.java——其余依赖自动编译。" +- icon: 🎓 + title: 适合学习 + desc: "非常适合教学示例和小型实用程序。" +support: + description: 自 JDK 22 起可用(2024 年 3 月) diff --git a/translations/content/zh-CN/tooling/single-file-execution.yaml b/translations/content/zh-CN/tooling/single-file-execution.yaml new file mode 100644 index 0000000..c89e77d --- /dev/null +++ b/translations/content/zh-CN/tooling/single-file-execution.yaml @@ -0,0 +1,18 @@ +--- +title: 单文件执行 +oldApproach: 两步编译 +modernApproach: 直接启动 +summary: "无需 javac 直接运行单文件 Java 程序。" +explanation: "Java 启动器可以在一个命令中编译并运行单个源文件。非常适合脚本、工具和探索,无需构建步骤。" +whyModernWins: +- icon: ⚡ + title: 一个命令 + desc: "java File.java 在一步中编译并运行。" +- icon: 🚀 + title: 无需构建工具 + desc: "非常适合脚本、工具和快速实验。" +- icon: 🎓 + title: 对初学者友好 + desc: "新开发者无需学习构建系统即可运行 Java。" +support: + description: 自 JDK 11 起广泛可用(2018 年 9 月) diff --git a/translations/strings/zh-CN.yaml b/translations/strings/zh-CN.yaml new file mode 100644 index 0000000..a81ced1 --- /dev/null +++ b/translations/strings/zh-CN.yaml @@ -0,0 +1,81 @@ +site: + title: java.evolved + tagline: Java 已进化。您的代码也可以。 + tagline_line1: Java 已进化。 + tagline_line2: 您的代码也可以。 + description: 现代 Java 代码片段集合。每个旧 Java 模式与其简洁的现代替代方案并排展示。 + heroSnippetCount: ✦ {{snippetCount}} 个现代模式 · Java 8 → Java 25 + heroOld: 旧版 + heroModern: 现代 + allComparisons: 所有对比 + snippetsBadge: '{{snippetCount}} 个代码片段' +nav: + allPatterns: ← 所有模式 + toggleTheme: 切换主题 + viewOnGitHub: 在 GitHub 上查看 + selectLanguage: 选择语言 +breadcrumb: + home: 首页 +sections: + codeComparison: 代码对比 + whyModernWins: 为什么现代方式更好 + oldApproach: 旧方式 + modernApproach: 现代方式 + sinceJdk: 自 JDK + difficulty: 难度 + jdkSupport: JDK 支持 + howItWorks: 工作原理 + relatedDocs: 相关文档 + relatedPatterns: 相关模式 +filters: + show: '显示:' + all: 全部 +difficulty: + beginner: 入门 + intermediate: 中级 + advanced: 高级 +search: + placeholder: 搜索代码片段… + noResults: 未找到结果。 + esc: ESC + searchTrigger: 搜索… + navigate: 导航 + open: 打开 + close: 关闭 +cards: + old: 旧版 + modern: 现代 + hoverHint: 悬停查看现代版 → + hoverHintRelated: 悬停查看现代版 ➜ + touchHint: 👆 点击或滑动 → +copy: + copy: 复制 + copied: 已复制! +share: + label: 分享 +view: + expandAll: 展开全部 + collapseAll: 收起全部 +stats: + modernPatterns: 现代模式 + jdkVersions: 覆盖的 JDK 版本 + categories: 分类 + linesOfPython: 所需 Python 代码行数 +footer: + tagline: Java 已进化。您的代码也可以。 + madeWith: 用 ❤️ 制作,作者 + and: 和 + inspiredBy: 灵感来自 + viewOnGitHub: 在 GitHub 上查看 +copilot: + headline: 使用 GitHub Copilot 现代化您的 Java 代码库。 + description: 让 Copilot 帮您自动将遗留模式迁移到现代 Java。 + appModernization: 应用现代化 → + javaGuide: Java 指南 → +support: + available: 可用 + preview: 预览 + experimental: 实验性 +untranslated: + notice: 此页面尚未翻译为{{localeName}}。 + viewInEnglish: 查看英文版