JAVA8, JAVA9, JAVA10, JAVA11, Spring5 principle and practice of the principles of the new features

Java10 it claims to have 109 new features, including 12 JEP.

It should be noted that this is not the official Java10 LTS versions of Oracle, so we can first understand the new features. Then wait for the release java11 consider using it in production

Feature List

Local variable type inference var keyword
GC improved memory management and garbage collector G1 parallel full
garbage collector interface
thread - local variable control
combined JDK code repository to a plurality of separate repository
new API: ByteArrayOutputStream
new API: List, Map, Set
new API: java.util.Properties
new API: collectors collector
other features
1, local variable type inference var keyword

This new feature will add some syntactic sugar Java - to simplify it and improve the developer experience. The new syntax will be reduced to writing Java-related verbosity, while maintaining a commitment to the static type safety.

This may be Java10 to developers to bring one of the biggest new features. Here mainly to see examples:

static void main public (String [] args) {
var = new new List the ArrayList <String> ();
List.add ( "Hello, World!");
System.out.println (List);
}
This is the most common use of . Note that the right side of the assignment statement, it is best to write a generic type, or there will be the following:

static void main public (String [] args) {
var = new new List the ArrayList <> ();
List.add ( "Hello, World!");
List.add (. 1);
List.add (1.01);
the System.out .println (List);
}
List anything can be installed, very unsafe. Js and other languages are different, after all, Java is a strongly typed language, so the following statement is being given to compile:

static void main public (String [] args) {
var = new new List the ArrayList <String> ();
List.add ( "Hello, World!");
System.out.println (List);

List new new = the ArrayList <Integer> (); // compiler error
}
Note: Note: Note: The following points using restriction

Initializing local variables
for the internal loop index variable
conventional variable for loop statement
public static void main (String [] args) {
// initialize local variable
var = new new List the ArrayList <String> ();
// for inner loop index variable
for ( S var: List) {
System.out.println (S);
}
// declare variables conventional for loop
for (var I = 0; I <list.size (); I ++) {
System.out.println (I) ;
}
}
the following these types of situations, not all of the var

Method parameters
global variables

public static var list = new ArrayList < String> (); // compiler given
public static List <String> list = new ArrayList <> (); // normal compiler
constructor parameters
return type
field
capture expression (or any other types of variable declarations)

2, GC and memory management improvements parallel full garbage collector G1

In JDK 10 has two JEP devoted to improving the current garbage collection element.
Java second JEP 10 is directed exactly parallel G1 GC (JEP 307), which focuses on improving the worst case latency G1 by GC completely parallel. G1 is the default GC 9 in Java, and the goal is to make this JEP G1 parallel.

3, the garbage collector Interface

This is not to allow developers to control garbage collection interface; it allows a further garbage collector JVM source code quickly and easily integrated interface.

4, the thread - local variable control

This is a fairly low-level changes within the JVM, it will now be allowed in without running a global point of realization of virtual machine security thread callback. This will make possible and stop individual threads become cheaper, not only to enable or stop all threads.

5, a plurality of code repository JDK combined into a single repository

In JDK9, has eight warehouses: root, corba, hotspot, jaxp, jaxws, jdk, langtools and nashorn. In JDK10 these will be merged into one, making the change across interdependent set of repository operation of atomic commit (atomic commit) possible.

6, 新增 API: ByteArrayOutputStream

String toString (Charset): overloaded toString (), by using the specified character set byte decoding, the contents of the buffer into a string.

7, the new API: List, Map, Set

The three interfaces are adding a new static method, copyOf (Collection). These functions return an unmodifiable list in accordance with their order of iteration, a map or a set of elements in a given set.

8, the new API: java.util.Properties

It added a new constructor that takes an int parameter. This creates an empty property list with no default value, and specifies the initial size to accommodate the number of elements specified, without the need for dynamic resizing. There is also a new method replace overloaded, Object accepts three parameters and returns a Boolean value. Only when the current to the specified value, will replace the entry specified key.

9, the new API: Collectors Collector

toUnmodifiableList ():
toUnmodifiableSet ():
toUnmodifiableMap (Function, Function):
toUnmodifiableMap (Function, Function, BinaryOperator):
four new methods return Collectors, the input element to gather the appropriate set of non-modifiable.

10, other characteristics

Thread Local handshake (JEP 312)

Other Unicode Language - a markup extension (JEP 314)

Java-based experimental JIT compiler

Root Certificate Authentication (CA)

Removal Tool javah (JEP 313)

Javah remove the tool from the JDK, this is very simple and very important.

At last

JDK10 upgrade magnitude fact, mainly to optimize the main, it did not bring much to the surprise of user characteristics. It is proposed that the majority of developers still look at September 2018 arrival Java11 it, the most important is that it is a LTS version Oh, it is used in the production.

Guess you like

Origin www.cnblogs.com/java188/p/12129151.html