Home Java javaTutorial What are the major features and enhancements introduced in Java 9?

What are the major features and enhancements introduced in Java 9?

Aug 31, 2023 pm 07:05 PM

Java 9引入了哪些主要功能和增强?

Oracle has released Java 9 version with a rich set of new features and many new Enhanced features.

Here are some of the important features and enhancements introduced in Java 9.

  • Factory method of collections: Factory method is a special type of static method that can be used to create unmodifiable Collection instances, which means we can use these methods to create Lists, Collections and Maps.
  • Java Platform Module System (JPMS): Java modules are a mechanism for bundling Java applications and Java packages into Java modules. It specifies which Java packages contain visible to other Java modules.
  • Private methods in the interfaces: The interface is allowed to include private and private static methods, thereby improving Code reusability inside the interface.
  • Java 9 REPL (Jshell) : Jshell is a REPL (read evaluation print loop) tool, Can be run from the command line. We can launch Jshell from the console and start entering and executing Java code directly.
  • Improvements in resource management: Java introduced a try-with-resources feature in Java 7 that can be automatically closed after use resource.
  • Diamond operator for anonymous inner classes: Java 9 introduced a new feature that allows us to use diamond## inside anonymous classes #operator.
  • Improvements in CompletableFuture API: The Java 9 version improves CompletableFuture API and solves some problems that occurred in Java 8. They add support for some delays and timeouts, some utility methods and better subclassing.
  • Responsive streaming: The reactive streaming API is a publish-subscribe framework that can be very easily implemented using Java language Asynchronous, Scalable and Parallel applications.
  • Improvements in process API: The process API is responsible for controlling and managing operating system processes, and has been significantly improved in this regard. ProcessHandle The class can provide the native process ID, startup time, accumulated CPU time, parameters, commands, users, parent processes and child processes of the process.
  • Improvements of the Optional class: In Java 9, the Optional class has three main improvements: Optional.ifPresentOrElse(), Optional.or() and Optional.stream().
  • Improvements to the Stream API: The Stream API has been improved and new methods have been added to the Stream interface. Added takeWhile (), dropWhile (), ofNullable () and iterate () methods to perform operations on stream elements.
  • Multi-resolution image API: The multi-resolution image API can encapsulate a set of images with different height and width , which can be customized according to our Query them on request.
  • HTTP/2 Client: HTTP/2 is a new version of HTTP protocol , focusing on data between the server and the client How it is framed and transmitted. In Java 9, the HTTP Client module is bundled as an incubator module and supports HTTP/2 with Backwards Compatibility.
  • Enhanced @Deprecated annotation : The @Deprecated annotation can provide more information about deprecated API. It can also provide a tool to analyze an application's static usage of deprecated APIs.

The above is the detailed content of What are the major features and enhancements introduced in Java 9?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to elegantly obtain entity class variable names to build database query conditions? How to elegantly obtain entity class variable names to build database query conditions? Apr 19, 2025 pm 11:42 PM

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

How to simplify field mapping issues in system docking using MapStruct? How to simplify field mapping issues in system docking using MapStruct? Apr 19, 2025 pm 06:21 PM

Field mapping processing in system docking often encounters a difficult problem when performing system docking: how to effectively map the interface fields of system A...

How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? Apr 19, 2025 pm 11:45 PM

Start Spring using IntelliJIDEAUltimate version...

Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Apr 19, 2025 pm 04:51 PM

Troubleshooting and solutions to the company's security software that causes some applications to not function properly. Many companies will deploy security software in order to ensure internal network security. ...

What is the difference between memory leaks in Java programs on ARM and x86 architecture CPUs? What is the difference between memory leaks in Java programs on ARM and x86 architecture CPUs? Apr 19, 2025 pm 11:18 PM

Analysis of memory leak phenomenon of Java programs on different architecture CPUs. This article will discuss a case where a Java program exhibits different memory behaviors on ARM and x86 architecture CPUs...

How to safely convert Java objects to arrays? How to safely convert Java objects to arrays? Apr 19, 2025 pm 11:33 PM

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

How to convert names to numbers to implement sorting within groups? How to convert names to numbers to implement sorting within groups? Apr 19, 2025 pm 01:57 PM

How to convert names to numbers to implement sorting within groups? When sorting users in groups, it is often necessary to convert the user's name into numbers so that it can be different...

How do I convert names to numbers to implement sorting and maintain consistency in groups? How do I convert names to numbers to implement sorting and maintain consistency in groups? Apr 19, 2025 pm 11:30 PM

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

See all articles