Java 10 in 5 minutes


From Java 9, Oracle will release a new version of Java every 6 months, starting with Java 10, which is to be released on march 20, 2018.

This blog highlights the major language and API changes in Java 10.

Local variable type inference

For local variables, specifying the type is not always needed anymore.

The Java compiler will infer the type of the variable from the right-hand side of the statement.
This will also work on method calls:

You can also use this on for loops:

Local variable type inference won’t compile in the following cases:

A word of caution

Correctly naming variables becomes even more important when using local variable type inference, so State Your Intentions when introducing a variable!

API changes

The List, Set and Map interfaces now support copy methods which return unmodifiable collection copies.

Collectors now also support collecting to unmodifiable collections for List, Set and Map.

Try it out

  • You can download an early access release of Java 10 here.
  • IntelliJ 2018.1 supports Java 10. Download it here.
  • We provided a demo java 10 application on GitHub. Download it here.

Een reactie plaatsen

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *