After the Java 8 release, Java 9 features release some major changes and improve many things. The biggest change is modular JDK in Java 9. In this post, we will see all Java 9 features.
Java 9 immutable collections improvement
Java 9 provides factory methods to create an immutable collection in java. These Factory Methods are used to create the Immutable List, Set, Map, and Map.Entry. We will cover it in detail.
Private methods in Interfaces
Java 8 has provided the default and static methods in java. But Java 9 introduced a private method in the interface. In the next post, we will see what is the need for a private method?
Java 9 Module System
In every release of Java, JDK size increases which creates problems for small devices. Java 9 decides to break this JDK into different modules. Java 9 provides the module system and here almost 95 modules.
Try with resource improvement
Try with resource was introduced in java 7. But there was some problem in trying with resources. To resolve the problem, java 9 provides some improvements. We will cover it in a separate section.
CompletableFuture API Improvements:
The CompletableFuture class was introduced in java 9 to provide some improvement to Future interface. The Future interface is used to hold the object that comes from callable. But there were some limitations.
Optional class improvement
The optional class was introduced in java 8 to resolve the NullPointerException. Every java program faces the NullPointerException. Java 8 provides a way to ignore but java 9 provides some methods to enhance the functionality.
The JShell stands for Java Shell and it is used to execute and test the java code. It is also known as REPL in java. Before java 9, we create a complete java program to start the programming in java, but Java 9 provides a tool JShell that provides the environment to run java code directly. We don’t need to write the complete code for logic.