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

Source: Internet
Author: User
Tags getstream java se






Java 9 just released a few months, a lot of things are not clear, now Java 10 is coming soon.



At this time I really want to say: Online JDK 7 or even JDK 6,JDK 8 is not cooked, JDK 9 released soon do not know what the thing, jdk 10 ...



Just learn Java classmate is not feel a face of force?!!



Even my old driver feels the same way!



Java update more and more quickly, we do technology to keep up with the pace, or it will always slow others a pat, this new things from abroad to domestic applications generally for a few years, if we know in advance and apply these new technologies to ourselves is not a bad thing.


New features for Java 10


With all that said, what are the features of Java 10 that will change the way we write code?!


1. local Variable type inference


Local variable type inference can be said to be the most notable feature in Java 10, which is another step taken by the Java language developer to simplify the writing of Java applications, as shown in.






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 that you can arbitrarily define a variable without having to specify the type of the 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();


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



When it comes to type inference, the introduction of generics from JDK 5 to the "<>" operator of JDK 7 allows the unbound type to initialize the list, to the lambda expression of JDK 8, and to the local variable type inference of JDK 10, the Java type inference is aggressively moving forward.


// This operator allows the list to be initialized without binding the type of ArrayList <> List <String> list = new LinkedList <> ();


Local variable type recommendations are limited to the following usage scenarios:


    • Local variable initialization
    • For loop internal index variable
    • Traditional for Loop declaration variables


Java officials say it cannot be used in the following places:


    • Method parameters
    • Constructor parameters
    • Method return type
    • Field
    • Capturing an expression (or any other type of variable declaration)
2.GC improvement and other housekeeping management


JDK 10 has 2 Jep specifically designed to improve the current garbage collection element.



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 scheduled for Java 10 is a parallel full GC (JEP 307) for G1, which focuses on improving G1 worst-case latency 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 will introduce a new way to execute callbacks on the thread, so it will be convenient to stop individual threads instead of stopping all threads or one.


4. Heap allocation on the standby memory device (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 314)


The goal is to enhance 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 (JEP 317)


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


7. Root certificate (JEP 319)


The goal is to open source root certificates in Oracle's Java SE.


8. Root Certificate Certification program (CA)


This makes openjdk more attractive to developers, and it is designed to reduce the differences between OPENJDK and Oracle JDK builds.


9. Integrate the JDK ecosystem into a single repository (JEP 296)


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


10. Delete the Native-header build tool (Javah) (JEP 313)


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


Early adopters


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're looking for Java 10 to try early, start now!


Early adopters Address: http://openjdk.java.net/projects/jdk/10/

The last sentiment


For the 1th new sex is really a big leap, other features more or less can bring the gospel to the developer. But what the final Java 10 will be, and perhaps add more usability to the new features or optimizations, we have to look forward to!



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!



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


Related Article

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.