2. Java has been evolving at a good pace since it was
introduced in early 90's.
With every passing year and each release it has tried to
keep pace with emerging market demands.
Let's take a look at 5 main features added to Java 9
3. 1. Modules
The result of Project Jigsaw, modules are the most important addition to Java 9.
Java is now modular which means the library packages are now organized as
modules.
It changes the way we design and build Java Applications.
It is different from OSGi.
It helps Programmers to be more productive. Managing and evolving modules is
easier.
4. 2. JShell : Read-Eval-Print loop for Java
A tool that allows you to develop and test Java code interactively.
Earlier:
class Sample{
public static void main(String[] a){
System.out.println("Hello !!");
}
}
5. JShell Cont ..
And now using JShell you can print Hello without writing other stuff.
You can type JShell at command line to get started.
And simple write
System.out.println("Hello !!");
6. 3. Private Methods in Interfaces
You can now add private methods to your Interfaces. This can help you to create
reusable code.
Example:
public interface Sample {
private void printMyStuff(String abc){
System.out.println(abc);
}
}
7. 4. Collections
Earlier you would write
List<Employee> empList = new ArrayList<>();
empList.add(new Employee(1, "Ankur"));
empList.add(new Employee(2, "Rohan"));
Now you can write
List<Employee> empList = List.of(new Employee(1, "Ankur"), new Employee(2,
"Rohan"));
Reason - Thanks to changes in Java 8. Interfaces can have default methods.
8. 5. Concurrency Updates
Java 8 introduced Streams.
Java 9 has gone a step ahead and added
● Reactive Streams publish-subscribe framework
● Enhancements to CompletableFuture class which was introduced in Java 8.
9. Other Notable Changes
Concurrency Updates
Java 8 introduced Streams. Java 9 has gone a step ahead and added
Reactive Streams publish-subscribe framework.
Enhancements to CompletableFuture class which was introduced in Java 8.
HTTP Client API to support HTTP/2 and WebSocket
The new incubator HTTP Client is capable of working with both HTTP/1.1 and
HTTP/2
10. Meet Ankur
He is a Software Architect who loves
to solve complex problems.
Blog
LinkedIn