Java 9 has only been out for a few months and a lot of things are still missing, but now Java 10 is coming.
JDK 8 is not yet ready. JDK 9 has just been released. JDK 10 is not yet ready.
Does the student who just learned Java feel a face to be forced? !!!!!!!!!
Even I, an old driver, felt the same way!
Java updates faster and faster, we do technology to keep up with the pace, or there will always be a slow others, this new things from abroad to domestic application generally take a few years, if we understand and apply these new technologies in advance is not bad for their own.
New features in Java 10
Having said that, what features will Java 10 have that will change the way we write code? !
Local variable type inference
Local variable type inference is arguably the most notable feature in Java 10, and it is another step taken by Java language developers to simplify the writing of Java applications, as shown in the figure below. \
\
This new feature will add some syntactic sugar to Java – simplifying it and improving the developer experience. The new syntax will reduce the verbosity associated with writing Java, while maintaining the promise of static type safety.
Local variable type inference will introduce the “var” keyword, which means that you can define variables without specifying their type, for example:
List = new ArrayList <String> (); Stream <String> Stream = getStream ();Copy the code
Will be replaced by this new syntax:
Var list = new ArrayList <String> (); Var stream = getStream ();Copy the code
After seeing is a bit JS namely inspect feeling?? More and more like JS? ! While type inference is not a new concept in Java, it is a big improvement in local variables.
When it comes to type inference, Java type inference has taken a big step forward, from the introduction of generics in JDK 5, to the “<>” operator in JDK 7 that allows List initialization without binding types, to Lambda expressions in JDK 8, and now local variable type inference in JDK 10.
List <String> List = new LinkedList <> ();Copy the code
Local variable types are recommended only for the following scenarios:
- Local variable initialization
- For loop internal index variable
- Traditional for loops declare variables
Java officially says that it cannot be used in the following places:
- The method parameters
- Constructor argument
- Method return type
- field
- Capture an expression (or any other type of variable declaration)
\
2.GC improvements and memory management
\
There are two Jeps in JDK 10 dedicated to improving the current garbage collection elements. \
The first garbage collector interface is (JEP 304), which will introduce a clean garbage collector interface to help improve source isolation of different garbage collectors.
The second JEP slated for Java 10 is the parallel full GC for G1 (JEP 307), which focuses on improving G1 worst-case wait times 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 perform callbacks on threads, so it will be handy to stop a single thread rather than all or none at all.
4. Heap allocation on standby memory devices (JEP 316)
\
Allows HotSpot VM to allocate Java object heap memory on an alternate 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 enable other Unicode extensions to the language markup syntax (BCP 47).
6. Experimental Java-based JIT compiler
\
Oracle wants Graal, its Java JIT compiler, to be used as an experimental JIT compiler on the Linux/X64 platform.
7. Root Certificate (JEP 319)
\
The goal is to open source the root certificate in Oracle’s Java SE.
8. Root Certificate Issuing 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. Ecological integration of the JDK into a single repository (JEP 296)
\
The main goal of this JEP is to perform some memory management and combine the many repositories in 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 early adopters
As with all other JDK releases, Oracle has released a Java 10 Initial release candidate that Java developers can download to test new features. If you’re excited about Java 10 and want to try it out early, get started now!
Early adopters address: openjdk.java.net/projects/jd…
One last thought
While the first feature is a big step forward, all the other features are more or less good news for developers. But it remains to be seen what Java 10 will eventually look like, perhaps with more practical new features or optimizations.
All you need to do now is familiarize yourself with JDK 8, which is now standard for many Internet companies. If you are still using JDK4-7, you are OUT.
Java 10 will revolutionize the way you write code in the near future!
This article comes from a Java giant friend’s public number, we can pay attention to it
Long press attention, more exciting