Know About New Features of Java 9

Posted By : Prajesh Rai | 29-Dec-2018

Java is a multipurpose and high-level programming language which is developed by Sun microsystem and later it acquired by Oracle.

Java introduce many versions like other software to get improved, with new features getting added in every major upgrade
Basically, Java 9 was a major upgrading of the java 8.Java 9 introduced lots of features for developers.Java 9 was released on July 27, 2019. In this blog, we look at some of the new features of Java 9.

Prerequisites (Software or Hardware)

a. jdk 1.9

b. sts, eclipse, intellij etc

c. Operating System (Linux, MacOS, Windows) with version information (Ubuntu 16, MacOS 10.12, Windows 10 Professional)

1.Improved Javadoc

Java 9 introduced improved java documentation feature. Previously developer search right tools for right documentation on Google. This new Javadoc came with API documentation itself, the output of Javadoc was HTML5 compliant. This improved Javadoc includes information on which JDK module the class or interface comes from.

2.JShell: the interactive Java REPL

In Java 9 Oracle has introduced a new tool called JShell. JShell stands for Java Shell and also known as REPL (Read Evaluate Print Loop). 
Many other languages like python already use this interactive Read-Eval-Print-Loop and now also introduced this.
Previously, if you want to write a simple program like print 'Hello World' for this we need to write almost 10 lines of code and need to understand the meaning of those lines, for the beginner it very difficult to understand by itself. But now using JShell you can easily write code.

3.Stream API Improvements:

Java 9 has added useful new methods to java.util.Stream interface. Stream API was introduced in Java 8. As we know that Stream is an interface and for collection in java. Java 9 has added four new methods of Stream API and these methods are a default.

a)dropWhile,
b)takeWhile,
c)ofNullable,
d) iterate.


4.Improvements in Process API:

Java 9 is coming with some needed improvements in Process API. In Java 9 Oracle has added some new classes and methods to ease the controlling and managing of OS processes.

Two new interfaces in Process API:

a)java.lang.ProcessHandle
b)java.lang.ProcessHandle.Info

5.Factory methods for collections

Many times, you want to create a collection in your Java program and fill it with some elements. In previously if you want to add value in Set, List, and Map than we have to use the add or put method as the number of values you want to add. In Java 9, Oracle has added a new method "of()" for List and Set interfaces. This method removes the several time call of add method during the addition of the values in Set and List interfaces

Empty Set example:

Set immutableSet = Set.of();

Non-Empty Set example:

Set immutableSet = Set.of("Mohan", "Sohan", "Rohan");

Conclusion

In this blog, I am just introducing some of the Java 9 features and those are the interesting bits! Of course, most people are looking other interesting features, but Java 9 will expand far beyond modules. Again, if I missed anything that you are excited about, please let me know in the comments.

Reference

https://docs.oracle.com/javase/9/

About Author

Author Image
Prajesh Rai

Prajesh Rai is a Java Developer. Currently, he is working on Spring-boot. He always interested to learn new technologies.

Request for Proposal

Name is required

Comment is required

Sending message..