The 10 new features of Java 10 will radically change the way you write code! __java

Source: Internet
Author: User
Tags garbage collection getstream java se

Java 9 only released for a few months, a lot of things do not understand, now Java 10 is coming again.

This time I really want to say: the online JDK 7 or even JDK 6,JDK 8 is not ripe, JDK 9 released soon do not know what things, jdk 10 ...

Just learn Java students are not feeling a face of forced ....

Even my old driver feels the same way.

Java update more and more quickly, we do technology to keep up with the pace, or always slow others a beat, this new things from abroad to domestic applications generally for several years, if we advance understanding and application of these new technologies is not bad for themselves.  

New features of Java 10

Having said so much, see what features Java 10 will have to change the way we write code.

1. Local Variable type inference

Local variable type inference is one of the most noteworthy features in Java 10, which is another step taken by the Java language developer to simplify the writing of Java applications, as shown in the following illustration.


This new feature will add some syntactic sugars to Java-simplifying it and improving the developer experience. The new syntax will reduce the verbosity associated with writing Java while maintaining a commitment to static type security.

Local variable type inference introduces the "var" keyword, which means you can define variables without specifying the type of variable, such as:

List <String> list = new ArrayList <String> ();

Stream <String> stream = GetStream ();

will be replaced by the following new syntax:

var list = new ArrayList <String> ();

var stream = GetStream ();

Read is not a bit of JS is the visual sense ... More and more like JS it? Although type inference is not a new concept in Java, it is a great improvement in local variables.

When it comes to type inference, the introduction of generics from JDK 5, to the "<>" operator of JDK 7 to allow the unbound type to initialize the list, then to the lambda expression of JDK 8, and then to the local variable type inference of JDK 10, Java type inference is taking a drastic step forward.

This operator allows the list to be initialized without binding the ArrayList <> type

List <String> list = new LinkedList <> ();

The local variable type recommendation is limited to the following usage scenarios:

Local variable initialization

For loop internal index variable

Traditional for Loop declaration variable

Java officials say it cannot be used in several places:

Method parameters

Constructor parameters

Method return type

Field

Capturing an expression (or any other type of variable declaration)


2.GC Improvement and memory management


There are 2 Jep in JDK 10 that are specifically designed to improve the current garbage collection elements.

The first garbage collector interface is (Jep 304), which introduces a pure garbage collector interface to help improve source code isolation for different garbage collectors.

The second Jep intended for Java 10 is a parallel complete GC (JEP 307) for G1, which focuses on improving the latency of G1 worst-case scenarios through full GC parallelism. G1 is the default GC in Java 9, and the goal of this Jep is to make G1 parallel.

3. Thread local handshake (Jep 312)

JDK 10 introduces a new method of executing callbacks on a thread, so it will be convenient to stop a single thread instead of stopping all threads or one.

4. Heap allocations on standby memory devices (Jep 316)


Allows the hotspot VM to allocate Java object Heap memory on the standby memory device, which will be specified by the user.

5. Other Unicode Languages-markup Extensions (JEP)


The goal is to enhance the Java.util.Locale and its associated APIs to implement other Unicode extensions of the Language markup Syntax (BCP 47).

6. Java-based experimental JIT compiler


Oracle wants to use its Java JIT compiler Graal as an experimental JIT compiler on the linux/x64 platform.

7. Root certificate (Jep 319)


The goal is to open the root certificate in Oracle's Java SE.

8. Root certificate certification (CA)


This will make openjdk more attractive to developers, and it also aims to reduce the differences between OPENJDK and Oracle JDK builds.

9. Integrate JDK ecology into a single repository (Jep 296)


The primary goal of this Jep is to perform some memory management and combine the numerous repositories of the JDK ecosystem into one repository.

10. Delete Tool Javah (Jep 313)


Removing the Javah tool from the JDK is simple and important.  

Java 10 Delicacy

Like all other JDK versions, Oracle has released a Java 10 initial candidate version that Java developers can download to test new features. If you want to try early on Java 10, start now.

Delicacy address: http://openjdk.java.net/projects/jdk/10/

The last point of thought

It is a big leap for the 1th new sex, and other features are more or less able to bring the gospel to developers. But what the final Java 10 will look like, and perhaps add more practical new features or optimizations, we have to expect.

Now it's time to get familiar with JDK 8, which is now standard for many internet companies. If you're still using jdk4-7, it's really going out.

In the near future, Java 10 will radically change the way you write code.

This article from a Java Daniel Friend's public number, you can pay attention to

Long by attention, more wonderful

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.