Java 简明教程

Java 12 - New Features

Java 12 是一个主要的特性版本,它为 JAVA 带来了许多特定于语言的变化。它遵循 Java 10 起引入的 Java 版本节奏,于 2019 年 3 月发布,仅比 Java 11 发布晚了 6 个月。

Java 12 is a major feature release and it has brought many language specific changes to JAVA. It followed the Java release cadence introduced Java 10 onwards and it was releasd on Mar 2019, just six months after Java 11 release.

Java 12 不是 LTS 版本。

Java 12 is a non-LTS release.

New Features

以下是 Java 12 中引入的主要新特性。

Following are the major new features which are introduced in Java 12.

  1. JVM Changes − JEP 189, JEP 346, JEP 344, and JEP 230.

  2. Switch Expressions − A preview feature allowing switch to use lambda expression.

  3. File.mismatch() method − File Comparison is made easy via mismatch method.

  4. Compact Number Formatting − Numbers can be formatted like 2K, 3M etc easily.

  5. Teeing Collector in Stream API − A merging operator on multiple collectors.

  6. String new methods − four new methods introduced to format a string.

  7. JEP 334 − JVM Constants API introduced.

  8. JEP 305 − A preview feature allowing pattern matching for instanceOf.

  9. Garbage Collection Enhancement