Java 10 features

It was released on March 20, 2018. It is a short-term release without LTS support. Let’s get into details.

Local-Variable Type Inference

Ahh…good’ol javascript. Well this is more like a sugar syntax. Instead of declaring inside a method a local variable with

private void method(){
   List<String> strings = new ArrayList<>();
   // do other stuff

we can now write:

private void method(){
   var strings = new ArrayList<>();
   // do other stuff

Unmodifiable Collections

Set, List and Map got copyOf(Collection c) method which basically returns an unmodifiable copy of the given input.

List<Integer> initialList = List.of(1,2); 
List<Integer> copyList = List.copyOf(initialList);

Stream got the ability to collect to an unmodifiable list.

List<Integer> evenList = List.of(2,4,6,7,8,9)
      .filter(i -> i % 2 == 0)

Optional Improvements

This got orElseThrow() method. It just throws a NoSuchElementException if no value is present.

                    .filter(i -> i % 5 == 0)

Garbage Collector Interface

This means the start to many implementations. As we will see in the next posts there are quite a few in the following releases.

Parallel Full GC for G1

Improves the G1 performance in the case of an unlikely event of a full GC. As we already know G1 does not performs a full GC only if rare cases.

Root Certificates

This is worth mentioning as is marks the start of a close collaboration between Oracle and OpenJDK which means security features like TLS are now supported in OpenJDK.

Container Updates

In 9 is was introduce support for docker containers. Now this is enabled by default and we could disable it by starting the JVM with the following command


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.